document-code
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseDocument Code
文档编写指南
Guide for adding and updating Syncpack's documentation website.
本文是为Syncpack文档网站添加和更新内容的指南。
Quick Decision
文档位置速查
What are you documenting?
| Adding/Updating... | Location |
|---|---|
| Command docs | |
| Config property | |
| Version group variant | |
| Semver group variant | |
| Status code | |
| FAQ | |
| Shared option partial | |
| Reusable component | |
你要编写/更新哪类文档?
| 文档类型 | 文件位置 |
|---|---|
| 命令文档 | |
| 配置属性文档 | |
| 版本组变体文档 | |
| 语义化版本组变体文档 | |
| 状态码文档 | |
| FAQ文档 | |
| 共享选项片段 | |
| 可复用组件 | |
Workflow
工作流程
- Read source — for commands,
cli.rsfor config,rcfile.rsfor status codesinstance_state.rs - Create/update MDX — Match existing structure exactly
- Add link identifier — Update in
globalReferenceLinksastro.config.mjs - Test locally — from
pnpm run devsite/ - Verify links — Check all links resolve
(IDENTIFIER)
- 阅读源码 —— 命令相关内容查看,配置相关查看
cli.rs,状态码相关查看rcfile.rsinstance_state.rs - 创建/更新MDX文件 —— 严格匹配现有文档结构
- 添加链接标识符 —— 更新中的
astro.config.mjsglobalReferenceLinks - 本地测试 —— 在目录下执行
site/pnpm run dev - 验证链接 —— 检查所有格式的链接是否能正常解析
(IDENTIFIER)
Source to Docs Mapping
源码与文档对应关系
| Source | Documentation |
|---|---|
| |
| |
| |
| |
| 源码文件 | 对应文档位置 |
|---|---|
| |
| |
| |
| |
Local Development
本地开发
bash
cd site
pnpm run dev # Start at http://localhost:4321/syncpack
pnpm run build # Verify build succeedsbash
cd site
pnpm run dev # 启动本地服务,地址为 http://localhost:4321/syncpack
pnpm run build # 验证构建是否成功Site Overview
网站概览
Command Documentation
命令文档规范
Each command has a corresponding file at .
site/src/content/docs/command/[command].mdx每个命令对应一个文档文件,路径为 。
site/src/content/docs/command/[command].mdxRequired Structure (in order)
必填结构(按顺序)
- Description of the command's purpose from end user perspective
- — Single bash code block with commented examples
## Examples - — Start with
## Optionscallout, then<QuoteFilters />for each option alphabetically (###last)--help
- 从用户视角描述命令的用途
- —— 单个bash代码块,包含带注释的示例
## 示例 - —— 以
## 选项提示框开头,然后按字母顺序列出每个选项(<QuoteFilters />放在最后)--help
Shared Option Partials
共享选项片段
Many commands share options. Define reusable partials at :
site/src/_partials/option/*.mdxmdx
import ConfigOption from "@partials/option/config.mdx";
<ConfigOption command="update" />多个命令会共享相同的选项。可在 定义可复用片段:
site/src/_partials/option/*.mdxmdx
import ConfigOption from "@partials/option/config.mdx";
<ConfigOption command="update" />Config Documentation
配置文档规范
Each config property has a file at .
site/src/content/docs/config/[property].mdx每个配置属性对应一个文档文件,路径为 。
site/src/content/docs/config/[property].mdxRequired Structure
必填结构
- Description of the config's purpose from end user perspective
- — Code block showing default (when applicable)
## Default Value - — Code blocks with commented examples
## Examples
- 从用户视角描述配置的用途
- —— 代码块展示默认值(如有)
## 默认值 - —— 代码块展示带注释的示例
## 示例
Version Groups and Semver Groups
版本组与语义化版本组
Each variant has its own page:
site/src/content/docs/version-groups/*.mdxsite/src/content/docs/semver-groups/*.mdx
每个变体对应独立页面:
site/src/content/docs/version-groups/*.mdxsite/src/content/docs/semver-groups/*.mdx
Required Structure
必填结构
- Description of the group's purpose from end user perspective
- — Code block per example, capture novel use cases
## Examples - —
## Configurationfor each config property###
- 从用户视角描述该组的用途
- —— 每个示例对应一个代码块,覆盖典型使用场景
## 示例 - —— 每个配置属性对应一个
## 配置标题###
Status Code Documentation
状态码文档规范
Each status code has a file at .
site/src/content/docs/status/[code].mdxReference page at explains the enum and its nested enums (, , ).
site/src/content/docs/reference/status-codes.mdxInstanceStateValidInstanceInvalidInstanceSuspectInstance每个状态码对应一个文档文件,路径为 。
site/src/content/docs/status/[code].mdx参考页面 解释了 枚举及其嵌套枚举(、、)。
site/src/content/docs/reference/status-codes.mdxInstanceStateValidInstanceInvalidInstanceSuspectInstanceFAQ Documentation
FAQ文档规范
- Create FAQ files at
site/src/faq/[id].mdx - Listed at via
/syncpack/faqsite/src/pages/faq.astro - Individual pages via
site/src/pages/faq/[id].astro
- 在 创建FAQ文件
site/src/faq/[id].mdx - 通过 在
site/src/pages/faq.astro页面展示所有FAQ/syncpack/faq - 单个FAQ页面路径为
site/src/pages/faq/[id].astro
Linking Between Pages
页面间链接规范
Use named identifiers in markdown links:
mdx
When using the [update](COMMAND_UPDATE) commandDefine identifiers in function in .
globalReferenceLinkssite/astro.config.mjs在Markdown链接中使用命名标识符:
mdx
使用 [update](COMMAND_UPDATE) 命令时标识符需在 的 函数中定义。
site/astro.config.mjsglobalReferenceLinksOpen Graph Images
Open Graph 图片
Generated by using Satori.
site/src/pages/og/[...path].png.ts由 生成,使用 Satori 库。
site/src/pages/og/[...path].png.tsTroubleshooting
常见问题排查
| Problem | Fix |
|---|---|
| Link not working | Check identifier in |
| Partial not rendering | Verify import path uses |
| OG image broken | Check |
| Build fails | Run |
| Page not appearing in sidebar | Check frontmatter and Starlight config |
| 问题现象 | 解决方法 |
|---|---|
| 链接无法正常跳转 | 检查 |
| 片段无法渲染 | 验证导入路径是否使用 |
| Open Graph图片加载失败 | 检查 |
| 构建失败 | 本地执行 |
| 页面未显示在侧边栏 | 检查页面前置元数据与Starlight配置 |
Checklist
提交前检查清单
Before submitting documentation:
- Structure matches existing pages of same type
- Link identifier added to
astro.config.mjs - Local dev server renders correctly
- Build succeeds ()
pnpm run build - All internal links resolve
提交文档前请完成以下检查:
- 文档结构与同类型现有页面一致
- 已在 中添加对应链接标识符
astro.config.mjs - 本地开发服务器能正常渲染页面
- 构建成功(执行 )
pnpm run build - 所有内部链接均可正常解析