Skip to content

docs: 添加 MCDR 插件文档#36

Merged
xieyuen merged 20 commits into
masterfrom
dev/docs
Mar 13, 2026
Merged

docs: 添加 MCDR 插件文档#36
xieyuen merged 20 commits into
masterfrom
dev/docs

Conversation

@xieyuen

@xieyuen xieyuen commented Mar 8, 2026

Copy link
Copy Markdown
Owner
  • 集成 Sphinx 文档构建工具及相关依赖包
  • 创建 MCDRpost 插件完整文档页面
  • 创建 KillServer 插件完整文档页面
  • 添加自定义 Handler API 文档
  • 配置文档主题及扩展功能
  • 设置多插件文档导航目录
  • 添加文档构建脚本和配置文件

- 从 mcdreforged 导入特定类型替代通配符导入
- 为 psi 变量添加 PluginServerInterface 类型注解
- 在属性验证方法中添加浮点数类型断言
- 补充关于布尔值配置项的注释说明
- 将事件定义移至独立的 events.py 文件
- 创建新的 entry.py 作为插件入口点文件
- 从 __init__.py 中移除所有实现代码
- 更新插件版本号至 1.0.1-beta.1
- 添加插件入口点配置
- 优化全局变量引用声明
- 改进 on_info 事件处理器以跳过玩家消息
- 在服务器已关闭时添加取消强制关闭任务的日志信息
- 移动事件监听器注册代码到条件判断之前避免重复执行
- 添加与 Just Kill It 插件的兼容性检查
- 当检测到冲突插件时自动禁用强制关闭功能并保存配置
- 修复代码结构确保正确的执行流程
- 将暂停提示文本提取为全局常量 PAUSE_PROMPT 元组
- 移除不必要的全局变量 is_world_saved 声明
- 修复插件兼容性检查方法调用,使用正确的 server.get_plugin_list()
- 更新玩家信息判断条件,使用 info.is_user 替代 info.is_player 并添加防熊注释
- 使用 PAUSE_PROMPT 常量替换硬编码的暂停提示字符串匹配
- 改进错误提示信息,明确指出 MC 服务器启动脚本中的 pause 命令问题
- 添加服务器启动、停止和世界保存事件的日志记录
- 实现服务器停止时的世界保存状态设置逻辑
- 新增环境检查函数验证MCDR处理器兼容性
- 检测并阻止与Just Kill It插件的冲突
- 优化插件加载时的配置验证流程
- 添加对跳转服处理器的不兼容提示
- 在配置禁用时添加返回语句避免后续代码执行
- 防止在 enable=False 情况下仍然注册事件监听器
- 更新插件版本号从 1.0.1-beta.1 到 1.0.1-beta.2
- 将原有独立的事件定义文件整合到统一的 ServerEvents 类中
- 创建 HandlerStorage 管理器统一管理事件处理器的注册和移除
- 使用 ServerEvent 统一处理服务器相关的所有事件类型
- 移除废弃的全局事件调度函数,改用新的事件分发机制
- 优化事件监听器的注册方式,提升代码可维护性
- 整合事件处理逻辑,减少重复代码结构
- 重命名 __register_dispatcher 函数为 __reg_dispatcher
- 修改内部函数参数名 event 为 e,提高代码简洁性
- 在函数定义间添加空行,改善代码可读性
- 移除多余空行,优化代码布局
- 更新函数调用以匹配新的函数名称
- 集成 Sphinx 文档构建工具及相关依赖包
- 创建 MCDRpost 插件完整文档页面
- 创建 KillServer 插件完整文档页面
- 添加自定义 Handler API 文档
- 配置文档主题及扩展功能
- 设置多插件文档导航目录
- 添加文档构建脚本和配置文件
@xieyuen xieyuen self-assigned this Mar 8, 2026
@xieyuen xieyuen added documentation Improvements or additions to documentation enhancement New feature or request MCDR-Plugins when mentioning MCDR-Plugins labels Mar 8, 2026
@qodo-code-review

Copy link
Copy Markdown

Review Summary by Qodo

Add Sphinx documentation site configuration for MCDR plugins

📝 Documentation

Grey Divider

Walkthroughs

Description
• Integrated Sphinx documentation build system with extensions
• Created comprehensive MCDRpost plugin documentation pages
• Created comprehensive KillServer plugin documentation pages
• Added custom Handler API documentation for MCDRpost
• Configured documentation theme, extensions and multi-plugin navigation
• Added documentation build scripts and configuration files
Diagram
flowchart LR
  A["Sphinx Configuration"] --> B["Documentation Build System"]
  B --> C["MCDRpost Docs"]
  B --> D["KillServer Docs"]
  C --> E["README & Custom Handler API"]
  D --> F["README & Usage Guide"]
  G["Build Scripts"] --> B
  H["Dependencies"] --> B
Loading

Grey Divider

File Changes

1. docs/source/conf.py ⚙️ Configuration changes +77/-0

Sphinx configuration with extensions and autodoc settings

docs/source/conf.py


2. docs/Makefile ⚙️ Configuration changes +20/-0

Unix/Linux documentation build script

docs/Makefile


3. docs/make.bat ⚙️ Configuration changes +35/-0

Windows documentation build script

docs/make.bat


View more (7)
4. docs/source/index.rst 📝 Documentation +16/-0

Main documentation index with plugin navigation

docs/source/index.rst


5. docs/source/mcdrpost/index.rst 📝 Documentation +8/-0

MCDRpost documentation index and table of contents

docs/source/mcdrpost/index.rst


6. docs/source/mcdrpost/readme.rst 📝 Documentation +363/-0

MCDRpost comprehensive documentation with usage and configuration

docs/source/mcdrpost/readme.rst


7. docs/source/mcdrpost/custom_handler.rst 📝 Documentation +150/-0

MCDRpost custom Handler API documentation with examples

docs/source/mcdrpost/custom_handler.rst


8. docs/source/kill_server/index.rst 📝 Documentation +7/-0

KillServer documentation index and table of contents

docs/source/kill_server/index.rst


9. docs/source/kill_server/readme.rst 📝 Documentation +138/-0

KillServer comprehensive documentation with features and events

docs/source/kill_server/readme.rst


10. pyproject.toml Dependencies +10/-0

Added Sphinx and documentation dependencies

pyproject.toml


Grey Divider

Qodo Logo

@qodo-code-review

qodo-code-review Bot commented Mar 8, 2026

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (4) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider


Action required

1. Docs build crashes🐞 Bug ⛯ Reliability
Description
Sphinx 配置无条件遍历仓库根目录下的 dependencies/,当该目录不存在时会在启动阶段抛出 FileNotFoundError,导致文档无法构建。该问题在任何执行
sphinx-build 的环境中都会稳定复现。
Code

docs/source/conf.py[R17-23]

+src = Path(__file__).parent.parent.parent / "src"
+dependencies = Path(__file__).parent.parent.parent / "dependencies"
+
+for directory in src.iterdir():
+    sys.path.append(str(directory))
+for directory in dependencies.iterdir():
+    sys.path.append(str(directory))
Evidence
conf.pydependencies.iterdir() 没有做存在性/目录性判断;而该仓库当前没有 dependencies/ 目录,因此 Sphinx 导入配置时就会崩溃。

docs/source/conf.py[17-23]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`docs/source/conf.py` 中对 `dependencies.iterdir()` 的无条件调用会在 `dependencies/` 不存在时抛出 `FileNotFoundError`,导致 Sphinx 无法启动并构建任何文档。
### Issue Context
当前仓库包含 `src/`,但并没有顶层 `dependencies/` 目录;因此该配置在默认仓库布局下必崩。
### Fix Focus Areas
- docs/source/conf.py[17-23]
### Suggested change
- 将遍历逻辑改为:仅当目录存在且为目录时才遍历;且仅将子目录加入 `sys.path`。例如:
- `for base in (src, dependencies):`
- `if base.is_dir():`
 - `for p in base.iterdir():`
   - `if p.is_dir(): sys.path.insert(0, str(p))`
- 若项目确实需要 `dependencies/`,请补充创建目录(至少空目录)并在文档构建说明/脚本中保证其存在。

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. RST directive invalid🐞 Bug ✓ Correctness
Description
custom_handler.rst 中的 autoclass 指令把 :no-index: 选项写在同一行,RST 语法不正确,Sphinx 解析该文件时很可能直接报错并中断构建。
Code

docs/source/mcdrpost/custom_handler.rst[R43-45]

+.. autoclass:: mcdrpost.api.OldSoundPlayer
+.. autoclass:: :no-index: mcdrpost.api.Item
+.. autoclass:: mcdrpost.api.Environment
Evidence
当前写法把 directive option 内联在指令行中;按照 reStructuredText/Sphinx 指令格式,选项应当放在后续缩进的选项块里。该行会导致解析失败或至少产生严重警告。

docs/source/mcdrpost/custom_handler.rst[38-45]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`docs/source/mcdrpost/custom_handler.rst` 存在无效的 Sphinx autodoc 指令写法:把 `:no-index:` 写在 `.. autoclass::` 同一行,导致 RST 语法不合法。
### Issue Context
该文件用于生成 API 文档;一旦该页解析失败,将影响整个文档站点构建。
### Fix Focus Areas
- docs/source/mcdrpost/custom_handler.rst[38-45]
### Suggested change
将该段修改为如下格式之一:
**保留 no-index:**

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

3. Markdown links break🐞 Bug ✓ Correctness
Description
文档中多处链接指向 .md 文件(如 custom_handler.md../MCDRpost-migration/README.md),但 Sphinx 配置未启用 Markdown
解析扩展,构建产物中这些链接会指向不存在的页面/资源。
Code

docs/source/mcdrpost/readme.rst[R351-362]

+点击 `此处 <custom_handler.md>`_ 跳转至 MCDRpost 的自定义 Handler 文档
+
+Future
+------
+
+在将来某一个时间(也许是 MCDR 不再支持 Python 3.10 的时候),
+MCDRpost 将会从 Python 3.10 迁移到 3.12 或者更高版本, 届时 MCDRpost 将会进入 4.x 版本
+
+.. rubric:: 脚注
+
+.. [#f1] Minecraft 1.20.5 用 components 代替了 tag, 导致命令不能执行, Minecraft 报错见 Flyky/MCDRpost#10
+.. [#f2] 理论上使用自定义 Handler 就可以适配任何版本, 但是插件**本身没有兼容**低于 1.13 的版本, 原因见 `Custom Handler <custom_handler.md>`_
Evidence
readme.rst 明确引用 .md 作为站内相对链接目标;同时 conf.pyextensions 未包含 MyST/recommonmark 等 Markdown
解析器,因此 .md 不会作为文档源被构建成 HTML 页面,最终形成死链。

docs/source/mcdrpost/readme.rst[20-22]
docs/source/mcdrpost/readme.rst[351-362]
docs/source/conf.py[28-50]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`docs/source/mcdrpost/readme.rst` 中存在对 `.md` 的相对链接,但当前 Sphinx 配置不构建 Markdown 页面,导致站点中出现死链。
### Issue Context
- 站内已经有 `docs/source/mcdrpost/custom_handler.rst`,但文档却链接到了 `custom_handler.md`。
- 还链接到了 `../MCDRpost-migration/README.md`(位于源码目录),Sphinx 默认不会把它当作可导航页面输出。
### Fix Focus Areas
- docs/source/mcdrpost/readme.rst[20-22]
- docs/source/mcdrpost/readme.rst[351-362]
- docs/source/conf.py[28-50]
### Suggested change (recommended)
- 将 `custom_handler.md` 改为指向已存在的 RST 页面,例如:
- 使用 `:doc:`:``:doc:`custom_handler```(或 ``:doc:`mcdrpost/custom_handler``` 视相对路径而定)
- 或直接链接 `custom_handler.html`/`custom_handler`(RST 方式)
- 对 `../MCDRpost-migration/README.md`:
- 若希望在站内可读:把内容迁移/拷贝到 `docs/source/.../*.rst` 并加入 toctree
- 若仅做参考:改为 GitHub 上的绝对链接(指向仓库文件),避免站内死链
### Alternative
- 若必须保留 Markdown:引入 `myst_parser` 并配置 `extensions`/`source_suffix`,同时把需要的 `.md` 文件移动/复制到 `docs/source` 下纳入构建。

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


4. Broken GitHub URL🐞 Bug ✓ Correctness
Description
KillServer 文档里存在错误的 GitHub 链接(缺少 .com),会导致用户点击后无法访问。
Code

docs/source/kill_server/readme.rst[R29-30]

+直接安装到 MCDR 的插件文件夹下即可, 可以从 `GitHub <https://github/xieyuen/MCDR-Plugins>`_
+或 `PluginCatalogue <https://mcdreforged.com/zh-CN/plugin/kill_server>`_ 手动下载插件文件
Evidence
链接目标写成了 https://github/...,不是合法的 GitHub 域名。

docs/source/kill_server/readme.rst[29-30]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
KillServer 文档中的 GitHub 链接域名拼写错误,导致死链。
### Issue Context
该链接位于“使用方法”段落,属于高频点击入口。
### Fix Focus Areas
- docs/source/kill_server/readme.rst[29-30]
### Suggested change
将:
- `https://github/xieyuen/MCDR-Plugins`
改为:
- `https://github.com/xieyuen/MCDR-Plugins`

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

ⓘ The new review experience is currently in Beta. Learn more

Grey Divider

Qodo Logo

@xieyuen xieyuen changed the title docs: 添加 MCDR 插件文档站点配置 docs: 添加 MCDR 插件文档 Mar 8, 2026
Comment thread docs/source/conf.py Outdated
Comment thread docs/source/mcdrpost/custom_handler.rst Outdated
xieyuen added 11 commits March 8, 2026 15:39
- 移除 Item 类的 no-index 指令以正确生成文档
- 添加了 contextlib.suppress 来优雅地处理文件不存在的情况
- 将依赖目录遍历包装在异常抑制块中
- 避免了 FileNotFoundError 导致的构建失败
- 保持了原有的系统路径添加逻辑
- 提高了文档构建过程的健壮性
- 添加 custom.css 文件支持删除线样式
- 配置 Sphinx 使用自定义 CSS 文件
- 添加删除线角色定义支持文档内删除线语法
- 更新 MCDRpost 文档的标题分隔线格式
- 修复代码块语法使用 code-block 替代 code
- 更新 README 中的链接指向 GitHub 仓库文件
- 使用自定义删除线语法替换原来的波浪线删除标记
- 更新各个章节标题的分隔线格式统一化
- 修复 API 文档中对自定义处理器的引用格式
- 配置 intersphinx 映射链接到 MCDR 官方文档
- 移除无用的注释代码和配置选项
- 新增 events.rst 文件详细记录 KillServer 事件系统
- 在索引中添加事件文档入口
- 简化 readme.rst 中的事件说明,指向新事件文档
- 移除全局 server 实例变量,直接使用 PluginServerInterface.psi() 获取实例
- 删除类属性中的事件类型注释,改为直接在常量定义处添加文档字符串
- 为所有事件常量添加详细的中文文档字符串说明
- 更新 dispatch 方法使用 psi() 静态方法替代全局实例调用
- 统一事件常量的命名规范和注释格式
- 将完整的模块路径引用改为相对引用格式
- 添加了 py:currentmodule 指令简化类引用
- 统一了文档中的类名显示方式
- 修复了文档格式化问题

fix(mcdrpost): 修正文档中的标记格式

- 修正了列表项中的特殊符号格式
- 确保文档渲染的一致性
- 将 GitHub 链接从 github/xieyuen/MCDR-Plugins 修正为 github.com/xieyuen/MCDR-Plugins
@xieyuen
xieyuen merged commit eacf53a into master Mar 13, 2026
3 checks passed
@xieyuen
xieyuen deleted the dev/docs branch March 13, 2026 16:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement New feature or request MCDR-Plugins when mentioning MCDR-Plugins

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant