docs: 重构 API 文档结构并修正源码准确性

- 重组文档目录结构: 每个模块的概述页移动到模块子目录
- 重命名 index.md 为 main.md
- 修正所有模块文档中的错误:
  - math: FromEuler→FromEulerAngles, TransformDirection 包含缩放, Box 是 OBB, Color::ToRGBA 格式
  - containers: 新增 operator==/!= 文档, 补充 std::hash DJB 算法细节
  - core: 修复 types 链接错误
  - debug: LogLevelToString 返回大写, timestamp 是秒, Profiler 空实现标注, Windows API vs ANSI
  - memory: 修复头文件路径, malloc vs operator new, 新增方法文档
  - resources: 修复 Shader/Texture 链接错误
  - threading: TaskSystem::Wait 空实现标注, ReadWriteLock 重入描述, LambdaTask 链接
- 验证: fix_links.py 确认 0 个断裂引用
This commit is contained in:
2026-03-19 00:22:30 +08:00
parent d0e16962c8
commit dc850d7739
1012 changed files with 26673 additions and 9222 deletions

View File

@@ -8,33 +8,42 @@
## 文档层次结构规范
### 文件命名
### 目录结构
文档文件统一命名为 `{module-name}.md`,按子系统组织目录结构
每个类对应一个文件夹,类文件夹下包含类总览页和方法详情页
```
docs/api/
├── index.md # 总索引
├── math/ # 数学库
├── containers/ # 容器
├── memory/ # 内存管理
├── threading/ # 线程与任务
├── debug/ # 调试与日志
├── core/ # 核心基础
├── rhi/ # RHI 抽象层
│ ├── d3d12/ # D3D12 后端
── opengl/ # OpenGL 后端
└── resources/ # 资源管理
├── index.md # 总索引
├── math/
│ ├── math.md # Math 模块总览
│ ├── vector3.md # Vector3 类总览
│ ├── dot.md # Dot 方法详情
│ ├── cross.md # Cross 方法详情
│ └── ...
├── containers/
│ ├── containers.md # Containers 模块总览
── array.md # Array 类总览
│ ├── emplace.md # Emplace 方法详情
│ ├── push.md # Push 方法详情
│ └── ...
└── ...
```
### 文档模板
**规则:**
- 模块总览页:`{module}/{module}.md`(如 `math/math.md``containers/containers.md`
- 类文件夹:`{class-name}/`(如 `array/``vector3/`
- 类总览页:`{class-name}/{class-name}.md`(如 `array/array.md`
- 方法详情页:`{class-name}/{method-name}.md`(如 `array/emplace.md`
### 类总览页模板
```markdown
# {类/结构体名称}
# {类名称}
**命名空间**: `{namespace}`
**类型**: `{type}` (`class` / `struct` / `class` (abstract) / `class` (template) / `class` (singleton) / `enum` / `struct`)
**类型**: `{type}`
**描述**: {一句话功能描述}
@@ -42,35 +51,12 @@ docs/api/
{模块功能详细介绍,包括设计目的和使用场景}
## {类型别名/子类型 1}(可选章节)
{子类型详细说明}
## 公共方法
### {方法分组 1}
| 方法 | 描述 |
|------|------|
| `{signature}` | {描述} |
### {方法分组 2}
| 方法 | 描述 |
|------|------|
| `{signature}` | {描述} |
## 公共成员struct/enum 时)
| 成员 | 类型 | 描述 |
|------|------|------|
| `{name}` | `{type}` | {description} |
## 枚举值enum 时)
| 值 | 描述 |
|----|------|
| `{EnumValue}` | {description} |
| [`Emplace`](./emplace.md) | 原地构造元素 |
| [`Push`](./push.md) | 末尾添加元素 |
## 使用示例
@@ -83,30 +69,64 @@ docs/api/
- [{文档名}](./{filename}.md) - {简短描述}
```
### 方法详情页模板
```markdown
# {类名称}::{方法名}
```cpp
{完整方法签名}
```
{方法详细描述,包括设计目的、使用场景、注意事项}
**参数:**
- `{param}` - {参数描述}
**返回:** {返回值描述}
**异常:** (如有)
**线程安全:** ✅ / ❌
**复杂度:** O(n)
**示例:**
```cpp
{}
```
## 相关文档
- [{类总览}](./{class}.md) - 返回类总览
```
---
## 必需字段规范
### 元信息(必须)
- `**命名空间**`: C++ 命名空间,如 `XCEngine::Math`、`XCEngine::RHI`
- `**类型**`: `class`、`struct`、`enum`、`class` (abstract)、`class` (template)、`class` (singleton)
- `**命名空间**`: C++ 命名空间,如 `XCEngine::Math`
- `**类型**`: `class`、`struct`、`enum`
- `**描述**`: 一句话功能描述
### 必需章节
1. **概述** - 模块功能介绍(设计目的、使用场景)
2. **公共方法** - 所有 public 方法按逻辑分组列出
2. **公共方法** - 表格形式,每个方法链接到详情页
3. **使用示例** - 完整可运行的代码示例
4. **相关文档** - @see 交叉引用
4. **相关文档** - 交叉引用
### 可选章节(按需添加)
### 方法详情页必需章节
- **类型别名/子类型** - 嵌套类型、结构体成员、枚举值
- **构造/析构**
- **运算符重载**
- **静态方法**
- **私有成员说明**
1. **方法签名** - 完整 C++ 签名
2. **详细描述** - 语义、使用场景、注意事项
3. **参数列表** - 每个参数的含义
4. **返回值** - 返回值含义
5. **示例代码** - 可运行的完整示例
6. **相关文档** - 返回类总览的链接
---
@@ -114,15 +134,14 @@ docs/api/
### 1. 格式校验
- [ ] 文档有且只有一个 `#` 一级标题
- [ ] 文档结构正确:模块有 `{module}/{module}.md`,类有 `{class}/{class}.md`
- [ ] 元信息完整:`命名空间`、`类型`、`描述`
- [ ] 每个方法有清晰的分组标题
- [ ] 代码块使用 ``` 包裹,语言标识正确(`cpp`、`json`
- [ ] 表格格式正确:`|header|`,有分隔行 `|------|------|`
- [ ] 类总览页的公共方法表格中,每个方法都有对应的详情页
- [ ] 代码块使用 ``` 包裹,语言标识正确(`cpp`
### 2. 引用校验
- [ ] `@see` / `- [xxx](./xxx.md)` 引用的文件存在
- [ ] 所有 `./{method}.md` 链接指向的文件存在
- [ ] 引用路径使用相对路径
- [ ] 不存在循环引用
@@ -139,189 +158,13 @@ docs/api/
## 生成流程
1. **扫描源码**:分析 `engine/include/XCEngine/` 目录下的头文件
1. **扫描源码**:分析指定目录下的头文件
2. **识别 API**:查找 `class`、`struct`、`enum`、`namespace`
3. **提取信息**:从源码中提取方法签名、成员变量、枚举值、文档注释
4. **生成文档**:按照上述模板生成 Markdown 文件
5. **校验输出**:运行校验规则,检查格式和引用
6. **输出报告**:列出生成的文档和发现的问题
---
## 各子系统文档清单
### Math 模块
- [x] math-overview.md
- [x] math-h.md (常量)
- [x] math-vector2.md
- [x] math-vector3.md
- [x] math-vector4.md
- [x] math-matrix3.md
- [x] math-matrix4.md
- [x] math-quaternion.md
- [x] math-transform.md
- [x] math-color.md
- [x] math-plane.md
- [x] math-sphere.md
- [x] math-box.md
- [x] math-bounds.md
- [x] math-aabb.md
- [x] math-frustum.md
- [x] math-ray.md
- [x] math-rect.md
### Containers 模块
- [x] container-overview.md
- [x] container-array.md
- [x] container-string.md
- [x] container-hashmap.md
### Memory 模块
- [x] memory-overview.md
- [x] memory-allocator.md
- [x] memory-linear-allocator.md
- [x] memory-pool-allocator.md
- [x] memory-proxy-allocator.md
- [x] memory-manager.md
### Threading 模块
- [x] threading-overview.md
- [x] threading-thread.md
- [x] threading-mutex.md
- [x] threading-spinlock.md
- [x] threading-readwritelock.md
- [x] threading-task.md
- [x] threading-lambdatask.md
- [x] threading-task-group.md
- [x] threading-task-system.md
- [x] threading-tasksystemconfig.md
### Debug 模块
- [x] debug-overview.md
- [x] debug-logger.md
- [x] debug-ilogsink.md
- [x] debug-consolelogsink.md
- [x] debug-filelogsink.md
- [x] debug-loglevel.md
- [x] debug-logcategory.md
- [x] debug-logentry.md
- [x] debug-profiler.md
### Core 模块
- [x] core-overview.md
- [x] core-types.md
- [x] core-smartptr.md
- [x] core-refcounted.md
- [x] core-event.md
- [x] core-filewriter.md
### RHI 模块(抽象层)
- [x] rhi-overview.md
- [x] rhi-device.md
- [x] rhi-factory.md
- [x] rhi-buffer.md
- [x] rhi-texture.md
- [x] rhi-shader.md
- [x] rhi-command-list.md
- [x] rhi-command-queue.md
- [x] rhi-swap-chain.md
- [x] rhi-fence.md
- [x] rhi-pipeline-state.md
- [x] rhi-sampler.md
- [x] rhi-pipeline-layout.md
- [x] rhi-descriptor-pool.md
- [x] rhi-capabilities.md
- [x] rhi-types.md
- [x] rhi-enums.md
### RHI D3D12 后端
- [x] d3d12-overview.md
- [x] d3d12-device.md
- [x] d3d12-buffer.md
- [x] d3d12-texture.md
- [x] d3d12-command-list.md
- [x] d3d12-command-queue.md
- [x] d3d12-swap-chain.md
- [x] d3d12-fence.md
- [x] d3d12-shader.md
- [x] d3d12-pipeline-state.md
- [x] d3d12-sampler.md
- [x] d3d12-root-signature.md
- [x] d3d12-descriptor-heap.md
- [x] d3d12-render-target-view.md
- [x] d3d12-depth-stencil-view.md
- [x] d3d12-shader-resource-view.md
- [x] d3d12-unordered-access-view.md
- [x] d3d12-constant-buffer-view.md
- [x] d3d12-command-allocator.md
- [x] d3d12-query-heap.md
- [x] d3d12-screenshot.md
- [x] d3d12-types.md
- [x] d3d12-enums.md
- [x] d3d12-common.md
### RHI OpenGL 后端
- [x] opengl-overview.md
- [x] opengl-device.md
- [x] opengl-buffer.md
- [x] opengl-texture.md
- [x] opengl-command-list.md
- [x] opengl-command-queue.md
- [x] opengl-swap-chain.md
- [x] opengl-fence.md
- [x] opengl-shader.md
- [x] opengl-pipeline-state.md
- [x] opengl-sampler.md
- [x] opengl-vertex-array.md
- [x] opengl-render-target-view.md
- [x] opengl-depth-stencil-view.md
### Resources 模块
- [x] resources-overview.md
- [x] resources-iresource.md
- [x] resources-resourcehandle.md
- [x] resources-iloader.md
- [x] resources-resourcemanager.md
- [x] resources-resourcecache.md
- [x] resources-asyncloader.md
- [x] resources-dependencygraph.md
- [x] resources-filesystem.md
- [x] resources-resourcetypes.md
- [x] resources-importsettings.md
---
## 输出格式
```json
{
"generated": [
{
"file": "docs/api/math/math-vector3.md",
"status": "created",
"classes": 1,
"methods": 15
}
],
"issues": [
{
"file": "docs/api/rhi/rhi-overview.md",
"type": "broken_reference",
"message": "../rhi/d3d12/d3d12-device.md 引用了不存在的文件,应为 ../rhi/d3d12/d3d12-overview.md"
}
]
}
```
4. **创建结构**:为每个类创建文件夹,生成类总览页和方法详情页
5. **生成文档**:按照上述模板生成 Markdown 文件
6. **校验输出**:运行校验规则,检查格式和引用
7. **输出报告**:列出生成的文档和发现的问题
---
@@ -333,7 +176,7 @@ docs/api/
```
AI 执行:
1. 扫描 `engine/include/XCEngine/` 源码目录
1. 扫描指定源码目录
2. 识别所有头文件中的 class/struct/enum
3. 对比现有文档,找出缺失文件和错误引用
4. 生成或修复 Markdown 文档