feat(zh): add Chinese translations in zh/ directory
Add Chinese (Simplified) translations for all documentation, organized under a dedicated zh/ directory that mirrors the English folder structure. Co-authored-by: tanqingkuang <tanqingkuang@users.noreply.github.com> Translations originally contributed by @tanqingkuang in #45. Restructured from *-CN.md suffix pattern into zh/ directory to prevent the EPUB builder (scripts/build_epub.py collect_folder_files) from picking up Chinese files via glob("*.md") inside module folders.
This commit is contained in:
127
zh/07-plugins/documentation/README.md
Normal file
127
zh/07-plugins/documentation/README.md
Normal file
@@ -0,0 +1,127 @@
|
||||
---
|
||||
name: 文档生成插件
|
||||
description: 为文档编写、同步和校验提供完整工作流
|
||||
tags: plugins, documentation, automation
|
||||
---
|
||||
|
||||
# 文档生成插件
|
||||
|
||||
这个插件把文档相关的命令、subagents、模板和 MCP 服务器打包在一起,帮助你生成、同步和校验文档。
|
||||
|
||||
## 特性
|
||||
|
||||
✅ 生成 API 文档
|
||||
✅ 创建和更新 README
|
||||
✅ 同步文档
|
||||
✅ 改进代码注释
|
||||
✅ 生成示例
|
||||
|
||||
## 包含内容
|
||||
|
||||
### 命令
|
||||
- [commands/generate-api-docs.md](commands/generate-api-docs.md) - 生成 API 文档
|
||||
- [commands/generate-readme.md](commands/generate-readme.md) - 生成 README
|
||||
- [commands/sync-docs.md](commands/sync-docs.md) - 同步文档
|
||||
- [commands/validate-docs.md](commands/validate-docs.md) - 校验文档
|
||||
|
||||
### Subagents
|
||||
- [agents/api-documenter.md](agents/api-documenter.md) - API 文档 subagent
|
||||
- [agents/code-commentator.md](agents/code-commentator.md) - 代码注释 subagent
|
||||
- [agents/example-generator.md](agents/example-generator.md) - 示例生成 subagent
|
||||
|
||||
### 模板
|
||||
- [templates/adr-template.md](templates/adr-template.md) - ADR 模板
|
||||
- [templates/api-endpoint.md](templates/api-endpoint.md) - API 端点模板
|
||||
- [templates/function-docs.md](templates/function-docs.md) - 函数文档模板
|
||||
|
||||
### MCP 服务器
|
||||
- GitHub 集成 - 用于文档同步
|
||||
|
||||
## 安装
|
||||
|
||||
```bash
|
||||
/plugin install documentation
|
||||
```
|
||||
|
||||
## 使用方式
|
||||
|
||||
### 生成 API 文档
|
||||
```bash
|
||||
/generate-api-docs
|
||||
```
|
||||
|
||||
### 创建 README
|
||||
```bash
|
||||
/generate-readme
|
||||
```
|
||||
|
||||
### 同步文档
|
||||
```bash
|
||||
/sync-docs
|
||||
```
|
||||
|
||||
### 校验文档
|
||||
```bash
|
||||
/validate-docs
|
||||
```
|
||||
|
||||
## 适用场景
|
||||
|
||||
- 想标准化项目文档产出
|
||||
- 想自动生成 README、API 文档和示例
|
||||
- 想同步多个文档之间的一致性
|
||||
- 想维护代码注释和示例质量
|
||||
|
||||
## 需求
|
||||
|
||||
- Claude Code 1.0+
|
||||
- GitHub 访问权限(可选)
|
||||
|
||||
## 示例工作流
|
||||
|
||||
```text
|
||||
用户:/generate-api-docs
|
||||
|
||||
Claude:
|
||||
1. 扫描 /src/api/ 下的所有 API 端点
|
||||
2. 委派给 api-documenter subagent
|
||||
3. 提取函数签名和 JSDoc
|
||||
4. 按模块 / 端点组织内容
|
||||
5. 使用 api-endpoint.md 模板
|
||||
6. 生成完整的 Markdown 文档
|
||||
7. 包含 curl、JavaScript 和 Python 示例
|
||||
|
||||
结果:
|
||||
✅ API 文档已生成
|
||||
📄 已创建文件:
|
||||
- docs/api/users.md
|
||||
- docs/api/auth.md
|
||||
- docs/api/products.md
|
||||
📊 覆盖率:23/23 个端点已文档化
|
||||
```
|
||||
|
||||
## 模板用途
|
||||
|
||||
### API 端点模板
|
||||
用于编写带完整示例的 REST API 文档。
|
||||
|
||||
### 函数文档模板
|
||||
用于编写单个函数或方法的说明文档。
|
||||
|
||||
### ADR 模板
|
||||
用于记录架构决策。
|
||||
|
||||
## 配置
|
||||
|
||||
为文档同步设置 GitHub token:
|
||||
```bash
|
||||
export GITHUB_TOKEN="your_github_token"
|
||||
```
|
||||
|
||||
## 最佳实践
|
||||
|
||||
- 文档尽量贴近代码
|
||||
- 随着代码变化同步更新文档
|
||||
- 提供可直接执行的示例
|
||||
- 定期校验文档有效性
|
||||
- 使用模板保持一致性
|
||||
14
zh/07-plugins/documentation/agents/api-documenter.md
Normal file
14
zh/07-plugins/documentation/agents/api-documenter.md
Normal file
@@ -0,0 +1,14 @@
|
||||
---
|
||||
name: api-documenter
|
||||
description: API 文档专家
|
||||
tools: read, write, grep
|
||||
---
|
||||
|
||||
# API 文档专家
|
||||
|
||||
创建全面的 API 文档:
|
||||
- 端点文档
|
||||
- 参数说明
|
||||
- 响应 schema
|
||||
- 代码示例(curl、JavaScript、Python)
|
||||
- 错误代码
|
||||
14
zh/07-plugins/documentation/agents/code-commentator.md
Normal file
14
zh/07-plugins/documentation/agents/code-commentator.md
Normal file
@@ -0,0 +1,14 @@
|
||||
---
|
||||
name: code-commentator
|
||||
description: 代码注释与内联文档专家
|
||||
tools: read, write, edit
|
||||
---
|
||||
|
||||
# 代码注释专家
|
||||
|
||||
改进代码文档:
|
||||
- JSDoc / docstring 注释
|
||||
- 内联说明
|
||||
- 参数说明
|
||||
- 返回类型文档
|
||||
- 使用示例
|
||||
14
zh/07-plugins/documentation/agents/example-generator.md
Normal file
14
zh/07-plugins/documentation/agents/example-generator.md
Normal file
@@ -0,0 +1,14 @@
|
||||
---
|
||||
name: example-generator
|
||||
description: 代码示例与教程专家
|
||||
tools: read, write
|
||||
---
|
||||
|
||||
# 示例生成专家
|
||||
|
||||
创建实用的代码示例:
|
||||
- 入门指南
|
||||
- 常见用例
|
||||
- 集成示例
|
||||
- 最佳实践
|
||||
- 故障排查场景
|
||||
15
zh/07-plugins/documentation/commands/generate-api-docs.md
Normal file
15
zh/07-plugins/documentation/commands/generate-api-docs.md
Normal file
@@ -0,0 +1,15 @@
|
||||
---
|
||||
name: 生成 API 文档
|
||||
description: 从源代码生成完整的 API 文档
|
||||
---
|
||||
|
||||
# API 文档生成器
|
||||
|
||||
生成完整的 API 文档:
|
||||
|
||||
1. 扫描 API 端点
|
||||
2. 提取函数签名和 JSDoc
|
||||
3. 按模块 / 端点组织内容
|
||||
4. 创建带示例的 Markdown
|
||||
5. 包含请求 / 响应 schema
|
||||
6. 添加错误文档
|
||||
15
zh/07-plugins/documentation/commands/generate-readme.md
Normal file
15
zh/07-plugins/documentation/commands/generate-readme.md
Normal file
@@ -0,0 +1,15 @@
|
||||
---
|
||||
name: 生成 README
|
||||
description: 创建或更新项目 README
|
||||
---
|
||||
|
||||
# README 生成器
|
||||
|
||||
生成完整的 README:
|
||||
|
||||
1. 项目概览与简介
|
||||
2. 安装说明
|
||||
3. 使用示例
|
||||
4. API 文档链接
|
||||
5. 贡献指南
|
||||
6. 许可证信息
|
||||
14
zh/07-plugins/documentation/commands/sync-docs.md
Normal file
14
zh/07-plugins/documentation/commands/sync-docs.md
Normal file
@@ -0,0 +1,14 @@
|
||||
---
|
||||
name: 同步文档
|
||||
description: 将文档与代码变更保持同步
|
||||
---
|
||||
|
||||
# 文档同步
|
||||
|
||||
同步文档与代码库:
|
||||
|
||||
1. 检测代码变更
|
||||
2. 找出过时文档
|
||||
3. 更新受影响的文档
|
||||
4. 验证示例是否仍然可用
|
||||
5. 更新版本号
|
||||
14
zh/07-plugins/documentation/commands/validate-docs.md
Normal file
14
zh/07-plugins/documentation/commands/validate-docs.md
Normal file
@@ -0,0 +1,14 @@
|
||||
---
|
||||
name: 校验文档
|
||||
description: 校验文档的完整性与准确性
|
||||
---
|
||||
|
||||
# 文档校验
|
||||
|
||||
校验文档质量:
|
||||
|
||||
1. 检查是否有损坏链接
|
||||
2. 验证代码示例
|
||||
3. 确保内容完整
|
||||
4. 检查格式
|
||||
5. 对照实际代码进行校验
|
||||
39
zh/07-plugins/documentation/templates/adr-template.md
Normal file
39
zh/07-plugins/documentation/templates/adr-template.md
Normal file
@@ -0,0 +1,39 @@
|
||||
# ADR [编号]:[标题]
|
||||
|
||||
## 状态
|
||||
[提议中 | 已接受 | 已弃用 | 已被替代]
|
||||
|
||||
## 背景
|
||||
我们正在看到的是什么问题,促使我们做出这个决策或变更?
|
||||
|
||||
## 决策
|
||||
我们提出和/或正在执行的变更是什么?
|
||||
|
||||
## 影响
|
||||
由于这项变更,哪些事情变得更容易或更困难?
|
||||
|
||||
### 正面影响
|
||||
- 收益 1
|
||||
- 收益 2
|
||||
|
||||
### 负面影响
|
||||
- 代价 1
|
||||
- 代价 2
|
||||
|
||||
### 中性影响
|
||||
- 参考事项 1
|
||||
- 参考事项 2
|
||||
|
||||
## 备选方案
|
||||
还考虑过哪些其他选项,以及为什么没有选择它们?
|
||||
|
||||
### 备选方案 1
|
||||
描述以及未选择的原因。
|
||||
|
||||
### 备选方案 2
|
||||
描述以及未选择的原因。
|
||||
|
||||
## 参考资料
|
||||
- 相关 ADR
|
||||
- 外部文档
|
||||
- 讨论链接
|
||||
101
zh/07-plugins/documentation/templates/api-endpoint.md
Normal file
101
zh/07-plugins/documentation/templates/api-endpoint.md
Normal file
@@ -0,0 +1,101 @@
|
||||
# [方法] /api/v1/[endpoint]
|
||||
|
||||
## 描述
|
||||
简要说明这个端点的作用。
|
||||
|
||||
## 身份验证
|
||||
所需的身份验证方式,例如 Bearer token。
|
||||
|
||||
## 参数
|
||||
|
||||
### 路径参数
|
||||
| 名称 | 类型 | 必填 | 描述 |
|
||||
|------|------|------|------|
|
||||
| id | string | 是 | 资源 ID |
|
||||
|
||||
### 查询参数
|
||||
| 名称 | 类型 | 必填 | 描述 |
|
||||
|------|------|------|------|
|
||||
| page | integer | 否 | 页码(默认:1) |
|
||||
| limit | integer | 否 | 每页条数(默认:20) |
|
||||
|
||||
### 请求体
|
||||
```json
|
||||
{
|
||||
"field": "value"
|
||||
}
|
||||
```
|
||||
|
||||
## 响应
|
||||
|
||||
### 200 OK
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"data": {
|
||||
"id": "123",
|
||||
"name": "示例"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 400 Bad Request
|
||||
```json
|
||||
{
|
||||
"success": false,
|
||||
"error": {
|
||||
"code": "VALIDATION_ERROR",
|
||||
"message": "无效输入"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 404 Not Found
|
||||
```json
|
||||
{
|
||||
"success": false,
|
||||
"error": {
|
||||
"code": "NOT_FOUND",
|
||||
"message": "资源未找到"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 示例
|
||||
|
||||
### cURL
|
||||
```bash
|
||||
curl -X GET "https://api.example.com/api/v1/endpoint" \
|
||||
-H "Authorization: Bearer YOUR_TOKEN" \
|
||||
-H "Content-Type: application/json"
|
||||
```
|
||||
|
||||
### JavaScript
|
||||
```javascript
|
||||
const response = await fetch('/api/v1/endpoint', {
|
||||
headers: {
|
||||
'Authorization': 'Bearer token',
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
});
|
||||
const data = await response.json();
|
||||
```
|
||||
|
||||
### Python
|
||||
```python
|
||||
import requests
|
||||
|
||||
response = requests.get(
|
||||
'https://api.example.com/api/v1/endpoint',
|
||||
headers={'Authorization': 'Bearer token'}
|
||||
)
|
||||
data = response.json()
|
||||
```
|
||||
|
||||
## 限流
|
||||
- 已认证用户每小时 1000 次请求
|
||||
- 公开端点每小时 100 次请求
|
||||
|
||||
## 相关端点
|
||||
- [GET /api/v1/related](#)
|
||||
- [POST /api/v1/related](#)
|
||||
50
zh/07-plugins/documentation/templates/function-docs.md
Normal file
50
zh/07-plugins/documentation/templates/function-docs.md
Normal file
@@ -0,0 +1,50 @@
|
||||
# 函数:`functionName`
|
||||
|
||||
## 描述
|
||||
简要说明这个函数的作用。
|
||||
|
||||
## 签名
|
||||
```typescript
|
||||
function functionName(param1: Type1, param2: Type2): ReturnType
|
||||
```
|
||||
|
||||
## 参数
|
||||
|
||||
| 参数 | 类型 | 必填 | 描述 |
|
||||
|------|------|------|------|
|
||||
| param1 | Type1 | 是 | param1 的说明 |
|
||||
| param2 | Type2 | 否 | param2 的说明 |
|
||||
|
||||
## 返回值
|
||||
**类型**:`ReturnType`
|
||||
|
||||
返回内容的说明。
|
||||
|
||||
## 抛出异常
|
||||
- `Error`:在输入无效时抛出
|
||||
- `TypeError`:在传入错误类型时抛出
|
||||
|
||||
## 示例
|
||||
|
||||
### 基本用法
|
||||
```typescript
|
||||
const result = functionName('value1', 'value2');
|
||||
console.log(result);
|
||||
```
|
||||
|
||||
### 高级用法
|
||||
```typescript
|
||||
const result = functionName(
|
||||
complexParam1,
|
||||
{ option: true }
|
||||
);
|
||||
```
|
||||
|
||||
## 备注
|
||||
- 其他说明或警告
|
||||
- 性能注意事项
|
||||
- 最佳实践
|
||||
|
||||
## 另请参阅
|
||||
- [相关函数](#)
|
||||
- [API 文档](#)
|
||||
Reference in New Issue
Block a user