我们基于mkdocs搭建了文档整理和发布流程:
mkdocs.yml: Main configuration filedocs/: Documentation source directory.github/workflows/docs.yml: GitHub Actions workflow for automatic deploymentdoc/DEPLOYMENT.md: Comprehensive deployment guideThis guide explains how to deploy the RoboCute documentation to GitHub Pages.
本指南说明如何将 RoboCute 文档部署到 GitHub Pages。
我们使用 MkDocs 和 Material 主题 来生成文档站点。
使用uv sync --extra dev来同步安装文档相关的依赖工具
gh-pages/ (root)编辑 mkdocs.yml 并更新以下字段:
site_url: https://your-username.github.io/robocute
repo_name: robocute
repo_url: https://github.com/your-username/robocute
mkdocs gh-deploy
仓库包含一个 GitHub Actions 工作流(.github/workflows/docs.yml),当更改推送到 main 分支时会自动构建和部署文档。
步骤:
.github/workflows/docs.ymlmain 分支gh-pages 分支https://your-username.github.io/robocute 提供访问对于手动部署,使用 mkdocs gh-deploy 命令:
mkdocs gh-deploy
此命令将:
gh-pages 分支要在不部署的情况下本地预览文档:
mkdocs serve
然后在浏览器中打开 http://127.0.0.1:8000。
要使用自定义域名(例如 docs.robocute.dev):
docs 目录中添加一个 CNAME 文件,包含您的域名:
docs.robocute.dev
mkdocs.yml:
site_url: https://docs.robocute.dev
your-username.github.io如果遇到构建错误:
python --version(应为 3.12+)pip list | grep mkdocsmkdocs.yml 语法mkdocs build --verbose如果 GitHub Pages 未更新:
gh-pages 分支存在且有内容gh-pages 分支