Skip to content

Commit

Permalink
docs: 加入docisfy文档,加入spinx文档
Browse files Browse the repository at this point in the history
  • Loading branch information
HenryXiaoYang committed Feb 2, 2025
1 parent 4bd69ce commit 47b2986
Show file tree
Hide file tree
Showing 57 changed files with 23,267 additions and 20 deletions.
41 changes: 41 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -173,3 +173,44 @@ cython_debug/
# XYBot
resource/robot_stat.json
WechatAPI/Client/login_stat.json
/WechatAPIDocs/_build/doctrees/environment.pickle
/WechatAPIDocs/_build/doctrees/index.doctree
/WechatAPIDocs/_build/html/_modules/WechatAPI/Client/base.html
/WechatAPIDocs/_build/html/_modules/WechatAPI/Client/chatroom.html
/WechatAPIDocs/_build/html/_modules/WechatAPI/Client/friend.html
/WechatAPIDocs/_build/html/_modules/WechatAPI/Client/hongbao.html
/WechatAPIDocs/_build/html/_modules/WechatAPI/Client/login.html
/WechatAPIDocs/_build/html/_modules/WechatAPI/Client/message.html
/WechatAPIDocs/_build/html/_modules/WechatAPI/Client/protect.html
/WechatAPIDocs/_build/html/_modules/WechatAPI/Client/tool.html
/WechatAPIDocs/_build/html/_modules/WechatAPI/Client/user.html
/WechatAPIDocs/_build/html/_modules/index.html
/WechatAPIDocs/_build/html/_sources/index.rst.txt
/WechatAPIDocs/_build/html/_static/scripts/furo.js
/WechatAPIDocs/_build/html/_static/scripts/furo.js.LICENSE.txt
/WechatAPIDocs/_build/html/_static/scripts/furo.js.map
/WechatAPIDocs/_build/html/_static/scripts/furo-extensions.js
/WechatAPIDocs/_build/html/_static/styles/furo.css
/WechatAPIDocs/_build/html/_static/styles/furo.css.map
/WechatAPIDocs/_build/html/_static/styles/furo-extensions.css
/WechatAPIDocs/_build/html/_static/styles/furo-extensions.css.map
/WechatAPIDocs/_build/html/_static/basic.css
/WechatAPIDocs/_build/html/_static/debug.css
/WechatAPIDocs/_build/html/_static/doctools.js
/WechatAPIDocs/_build/html/_static/documentation_options.js
/WechatAPIDocs/_build/html/_static/file.png
/WechatAPIDocs/_build/html/_static/language_data.js
/WechatAPIDocs/_build/html/_static/minus.png
/WechatAPIDocs/_build/html/_static/plus.png
/WechatAPIDocs/_build/html/_static/pygments.css
/WechatAPIDocs/_build/html/_static/searchtools.js
/WechatAPIDocs/_build/html/_static/skeleton.css
/WechatAPIDocs/_build/html/_static/sphinx_highlight.js
/WechatAPIDocs/_build/html/_static/translations.js
/WechatAPIDocs/_build/html/.buildinfo
/WechatAPIDocs/_build/html/genindex.html
/WechatAPIDocs/_build/html/index.html
/WechatAPIDocs/_build/html/objects.inv
/WechatAPIDocs/_build/html/py-modindex.html
/WechatAPIDocs/_build/html/search.html
/WechatAPIDocs/_build/html/searchindex.js
20 changes: 20 additions & 0 deletions WechatAPIDocs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = .
BUILDDIR = _build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
17 changes: 17 additions & 0 deletions WechatAPIDocs/_templates/custom-toc.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<div class="sidebar-tree">
<p class="caption"><span class="caption-text">重要函数导航</span></p>
<ul>
{% for category, functions in important_functions.items() %}
<li class="toctree-l1">
<p class="caption"><span class="caption-text">{{ category }}</span></p>
<ul>
{% for title, ref in functions %}
<li class="toctree-l2">
<a class="reference internal" href="{{ ref | safe }}">{{ title }}</a>
</li>
{% endfor %}
</ul>
</li>
{% endfor %}
</ul>
</div>
7 changes: 7 additions & 0 deletions WechatAPIDocs/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
cd "$(dirname "$0")" || exit
make clean
make html

rm -rf ../docs/WechatAPIClient/*
cp -r _build/html/* ../docs/WechatAPIClient || exit
146 changes: 146 additions & 0 deletions WechatAPIDocs/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
# Configuration file for the Sphinx documentation builder.
#
# For the full list of built-in configuration values, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information

import os
import sys
import sphinx_rtd_theme

sys.path.insert(0, os.path.abspath('..'))

html_theme = 'furo'

project = 'WechatAPI'
copyright = '2025, HenryXiaoYang'
author = 'HenryXiaoYang'

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.napoleon', # 支持Google风格的文档字符串
'sphinx.ext.viewcode'
]

templates_path = ['_templates']
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']

language = 'zh_CN'

# Napoleon设置
napoleon_google_docstring = True
napoleon_numpy_docstring = False
napoleon_include_init_with_doc = True
napoleon_include_private_with_doc = True
napoleon_include_special_with_doc = True
napoleon_use_admonition_for_examples = True
napoleon_use_admonition_for_notes = True
napoleon_use_admonition_for_references = True
napoleon_use_ivar = True
napoleon_use_param = True
napoleon_use_rtype = True
napoleon_type_aliases = None

html_title = "XYBotV2"
html_sidebars = {
"**": [
"sidebar/scroll-start.html",
"sidebar/brand.html",
"sidebar/search.html",
"sidebar/navigation.html",
"custom-toc.html",
"sidebar/scroll-end.html"
]
}

# furo主题配置
html_theme_options = {
"sidebar_hide_name": False,
"light_css_variables": {
"color-brand-primary": "#2962ff",
"color-brand-content": "#2962ff",
},
"navigation_with_keys": True,
}

# 重要函数导航列表
important_functions = {
"登录": [
("检查WechatAPI是否在运行", "index.html#WechatAPI.Client.login.LoginMixin.is_running"),
("获取登录二维码", "index.html#WechatAPI.Client.login.LoginMixin.get_qr_code"),
("二次登录(唤醒登录)", "index.html#WechatAPI.Client.login.LoginMixin.awaken_login"),
("检查登录的UUID状态", "index.html#WechatAPI.Client.login.LoginMixin.check_login_uuid"),
("获取登录缓存信息", "index.html#WechatAPI.Client.login.LoginMixin.get_cached_info"),
("登出当前账号", "index.html#WechatAPI.Client.login.LoginMixin.log_out"),
("发送心跳包", "index.html#WechatAPI.Client.login.LoginMixin.heartbeat"),
("开始自动心跳", "index.html#WechatAPI.Client.login.LoginMixin.start_auto_heartbeat"),
("停止自动心跳", "index.html#WechatAPI.Client.login.LoginMixin.stop_auto_heartbeat"),
("获取自动心跳状态", "index.html#WechatAPI.Client.login.LoginMixin.get_auto_heartbeat_status")
],
"消息": [
("同步消息", "index.html#WechatAPI.Client.message.MessageMixin.sync_message"),
("发送文本消息", "index.html#WechatAPI.Client.message.MessageMixin.send_text_message"),
("发送图片消息", "index.html#WechatAPI.Client.message.MessageMixin.send_image_message"),
("发送语音消息", "index.html#WechatAPI.Client.message.MessageMixin.send_voice_message"),
("发送视频消息", "index.html#WechatAPI.Client.message.MessageMixin.send_video_message"),
("发送链接消息", "index.html#WechatAPI.Client.message.MessageMixin.send_link_message"),
("发送名片消息", "index.html#WechatAPI.Client.message.MessageMixin.send_card_message"),
("发送应用(xml)消息", "index.html#WechatAPI.Client.message.MessageMixin.send_app_message"),
("发送表情消息", "index.html#WechatAPI.Client.message.MessageMixin.send_emoji_message"),
("转发图片消息", "index.html#WechatAPI.Client.message.MessageMixin.send_cdn_img_msg"),
("转发视频消息", "index.html#WechatAPI.Client.message.MessageMixin.send_cdn_video_msg"),
("转发文件消息", "index.html#WechatAPI.Client.message.MessageMixin.send_cdn_file_msg"),
("撤回消息", "index.html#WechatAPI.Client.message.MessageMixin.revoke_message")
],
"用户": [
("获取个人二维码", "index.html#WechatAPI.Client.user.UserMixin.get_my_qrcode"),
("获取用户信息", "index.html#WechatAPI.Client.user.UserMixin.get_profile"),
("检查是否登录", "index.html#WechatAPI.Client.user.UserMixin.is_logged_in")
],
"群聊": [
("获取群聊信息", "index.html#WechatAPI.Client.chatroom.ChatroomMixin.get_chatroom_info"),
("获取群聊公告", "index.html#WechatAPI.Client.chatroom.ChatroomMixin.get_chatroom_announce"),
("获取群聊成员列表", "index.html#WechatAPI.Client.chatroom.ChatroomMixin.get_chatroom_member_list"),
("获取群聊二维码", "index.html#WechatAPI.Client.chatroom.ChatroomMixin.get_chatroom_qrcode"),
("添加群成员(群聊最多40人)", "index.html#WechatAPI.Client.chatroom.ChatroomMixin.add_chatroom_member"),
("邀请群聊成员(群聊大于40人)", "index.html#WechatAPI.Client.chatroom.ChatroomMixin.invite_chatroom_member")
],
"好友": [
("获取联系人信息", "index.html#WechatAPI.Client.friend.FriendMixin.get_contact"),
("获取联系人详情", "index.html#WechatAPI.Client.friend.FriendMixin.get_contract_detail"),
("获取联系人列表", "index.html#WechatAPI.Client.friend.FriendMixin.get_contract_list"),
("获取用户昵称", "index.html#WechatAPI.Client.friend.FriendMixin.get_nickname"),
("接受好友请求", "index.html#WechatAPI.Client.friend.FriendMixin.accept_friend"),
],
"红包": [
("获取红包详情", "index.html#WechatAPI.Client.hongbao.HongBaoMixin.get_hongbao_detail")
],
"工具": [
("检查数据库状态", "index.html#WechatAPI.Client.tool.ToolMixin.check_database"),
("设置步数", "index.html#WechatAPI.Client.tool.ToolMixin.set_step"),
("下载高清图片", "index.html#WechatAPI.Client.tool.ToolMixin.download_image"),
("下载视频", "index.html#WechatAPI.Client.tool.ToolMixin.download_video"),
("下载语音文件", "index.html#WechatAPI.Client.tool.ToolMixin.download_voice"),
("下载附件", "index.html#WechatAPI.Client.tool.ToolMixin.download_attach"),
("base64转字节", "index.html#WechatAPI.Client.tool.ToolMixin.base64_to_byte"),
("base64转文件", "index.html#WechatAPI.Client.tool.ToolMixin.base64_to_file"),
("字节转base64", "index.html#WechatAPI.Client.tool.ToolMixin.byte_to_base64"),
("文件转base64", "index.html#WechatAPI.Client.tool.ToolMixin.file_to_base64"),
("silk的base64转wav字节", "index.html#WechatAPI.Client.tool.ToolMixin.silk_base64_to_wav_byte"),
("silk字节转wav字节", "index.html#WechatAPI.Client.tool.ToolMixin.silk_byte_to_byte_wav_byte"),
("WAV字节转AMR的base64", "index.html#WechatAPI.Client.tool.ToolMixin.wav_byte_to_amr_base64"),
("WAV字节转AMR字节", "index.html#WechatAPI.Client.tool.ToolMixin.wav_byte_to_amr_byte"),
("WAV字节转silk的base64", "index.html#WechatAPI.Client.tool.ToolMixin.wav_byte_to_silk_base64"),
("WAV字节转silk字节", "index.html#WechatAPI.Client.tool.ToolMixin.wav_byte_to_silk_byte"),
]
}

# 添加 HTML 上下文
html_context = {
'important_functions': important_functions
}
81 changes: 81 additions & 0 deletions WechatAPIDocs/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
WechatAPIClient
------------------------------

基础
~~~~~~~

.. automodule:: WechatAPI.Client.base
:members:
:undoc-members:
:show-inheritance:

登录
~~~~~~~

.. automodule:: WechatAPI.Client.login
:members:
:undoc-members:
:show-inheritance:

消息
~~~~~~~

.. automodule:: WechatAPI.Client.message
:members:
:undoc-members:
:show-inheritance:

用户
~~~~~~~

.. automodule:: WechatAPI.Client.user
:members:
:undoc-members:
:show-inheritance:

群聊
~~~~~~~

.. automodule:: WechatAPI.Client.chatroom
:members:
:undoc-members:
:show-inheritance:

好友
~~~~~~~

.. automodule:: WechatAPI.Client.friend
:members:
:undoc-members:
:show-inheritance:

红包
~~~~~~~

.. automodule:: WechatAPI.Client.hongbao
:members:
:undoc-members:
:show-inheritance:

保护
~~~~~~~

.. automodule:: WechatAPI.Client.protect
:members:
:undoc-members:
:show-inheritance:

工具
~~~~~~~

.. automodule:: WechatAPI.Client.tool
:members:
:undoc-members:
:show-inheritance:

索引
====

* :ref:`search`


35 changes: 35 additions & 0 deletions WechatAPIDocs/make.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@ECHO OFF

pushd %~dp0

REM Command file for Sphinx documentation

if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=.
set BUILDDIR=_build

%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.https://www.sphinx-doc.org/
exit /b 1
)

if "%1" == "" goto help

%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end

:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%

:end
popd
3 changes: 3 additions & 0 deletions WechatAPIDocs/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
sphinx~=8.1.3
sphinx-rtd-theme~=3.0.2
furo~=2024.8.6
Empty file added docs/.nojekyll
Empty file.
Loading

0 comments on commit 47b2986

Please sign in to comment.