跳至内容

文档工作流程 📚

本指南涵盖以下内容的文档编写、构建和维护 Ultralytics项目的文档编写和维护。

文件结构 🗂️

主要文献网站

存储库结构

docs/
├── en/              # English docs
│   ├──      # Homepage
│   ├── guides/      # User guides
│   ├── tasks/       # Task-specific docs
│   ├── models/      # Model documentation
│   └── reference/   # API reference
├── zh/              # Chinese translations
└── overrides/       # Theme customizations

撰写文档 ✍️

风格指南

  • 简洁明了:快速切入主题
  • 主动语态:"训练模型 "而不是 "训练模型"
  • 代码示例:显示每个概念的工作代码
  • 直观教具:使用图片/图表
  • 格式一致:遵循现有页面结构

Markdown 格式

---
description: Brief page description for SEO
keywords: relevant, keywords, for, search
---

# Page Title

Brief introduction explaining what this page covers.

## Section Heading

Content with examples:

```python
from ultralytics import YOLO

# Load pretrained model
model = YOLO("yolo11n.pt")
results = model("image.jpg")
```

### Key points:

- Use bullet points for lists
- Keep paragraphs short
- Include links to related pages

### Code Examples

- **Minimal**: Show only relevant code
- **Runnable**: Examples should work copy-paste (test with actual [YOLO models](https://docs.ultralytics.com/models/yolo11/))
- **Commented**: Explain non-obvious parts
- **Tested**: Verify examples work with current version

```python
from ultralytics import YOLO

# Load pretrained model
model = YOLO("yolo11n.pt")

# Train on custom data
results = model.train(data="coco8.yaml", epochs=3)
```

图片和媒体

存储在存储库中或使用 CDN:

![Alt text](https://path/to/image.png)

Keep image sizes reasonable (<500KB when possible).

建筑文件 🔨

地方发展

安装依赖项:

pip install -e ".[docs]"

在当地建设和服务:

mkdocs serve

参观 http://127.0.0.1:8000 来预览。

MkDocs 配置

主要配置在 mkdocs.yml:

site_name: Ultralytics Docs
theme:
    name: material
    palette:
        - scheme: slate
plugins:
    - search
    - ultralytics

API 文档 📖

API 参考资料由 docstrings 自动生成。请查看所有模块的完整 API 参考资料

def train(self, data, epochs=100, batch=16):
    """
    Train the model on a dataset.

    Args:
        data (str): Path to data YAML file
        epochs (int): Number of training epochs
        batch (int): Batch size

    Returns:
        (Results): Training results

    Examples:
        ```python
        model = YOLO("yolo11n.pt")
        results = model.train(data="coco8.yaml", epochs=100)
        ```
    """

关键要素:

  • 简要说明:一行摘要
  • 参数带类型的参数描述
  • 返回值返回值说明
  • 示例:工作代码示例

添加新页面 📄

1.创建Markdown 文件

# Create new guide
touch docs/en/guides/new-guide/

2.更新导航

编辑 mkdocs.yml:

nav:
    - Home: 
    - Guides:
          - New Guide: guides/new-guide/

3.撰写内容

遵循文体指南并举例说明。

4.测试构建

mkdocs serve

5.提交公关

遵循公关流程的开发工作流程

翻译 🌐

添加翻译

  1. 将English 版本复制到语言目录:
cp docs/en/page/ docs/zh/page/
  1. 翻译内容,保留English代码示例

  2. 更新 mkdocs.yml 备用链接

翻译指南

  • 用English 保留专业术语YOLO、mAP、FPS)
  • 翻译说明和解释
  • 保持与English 相同的结构
  • 在English 版本发生变化时更新译文

文件 CI 🤖

CI 自动进行:

  • 为每个 PR 建立文档
  • 检查断开的链接
  • 验证markdown 符格式
  • 合并到主系统时部署到生产系统

修复构建错误

常见问题:

  • 断开的链接:修复或删除无效链接
  • 缺少图像:添加图像或更新路径
  • YAML 无效:修复前置事项语法
  • 插件错误:检查插件配置

最佳做法 ✅

内容组织

  • 逻辑结构:分组相关内容
  • 逐步公开:简单 → 高级
  • 交叉链接:链接到相关页面
  • 搜索优化:使用清晰的标题和描述

维护

  • 保持最新:更新新功能
  • 删除过时的内容删除过时内容
  • 检查链接:定期修复损坏的链接
  • 用户反馈:解决常见问题

无障碍环境

  • Alt 文本:为屏幕阅读器描述图像
  • 标题清晰:使用适当的标题层次
  • 语言通俗易懂:尽可能避免行话
  • 代码对比:确保代码块可读

资源 📚



📅创建于 6 天前 ✏️已更新 6 天前