write-docs
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseWrite documentation
编写文档
This skill covers how to write and update tldraw SDK documentation.
本指南介绍如何编写和更新tldraw SDK文档。
Location
存放位置
All documentation lives in . The main categories are:
apps/docs/content/| Directory | Purpose |
|---|---|
| SDK documentation articles |
| Release notes (see write-release-notes skill) |
| Example documentation |
| Quickstart and setup guides |
所有文档都位于目录下。主要分类如下:
apps/docs/content/| 目录 | 用途 |
|---|---|
| SDK文档文章 |
| 发布说明(请参考write-release-notes技能) |
| 示例文档 |
| 快速入门与设置指南 |
Process
流程
1. Understand the scope
1. 明确范围
Before writing:
- Identify the target audience (new users, experienced developers, API reference)
- Check existing docs that cover related topics
- Look at relevant examples in
apps/examples/ - Read the API types and comments in the source code
开始写作前:
- 确定目标受众(新用户、资深开发者、API参考读者)
- 查阅涵盖相关主题的现有文档
- 查看中的相关示例
apps/examples/ - 阅读源代码中的API类型和注释
2. Create the file
2. 创建文件
Create a new file in the appropriate directory with frontmatter:
.mdxyaml
---
title: Feature name
status: published
author: steveruizok
date: 3/22/2023
order: 1
keywords:
- keyword1
- keyword2
---在对应目录下创建新的文件,并添加以下前置内容:
.mdxyaml
---
title: Feature name
status: published
author: steveruizok
date: 3/22/2023
order: 1
keywords:
- keyword1
- keyword2
---3. Write the content
3. 撰写内容
Follow the structure:
- Overview — 1-2 paragraphs on what and why
- Basic usage — The simplest working example
- Details — Deeper explanation with more examples
- Edge cases — Advanced patterns, gotchas
- Links — Related docs and examples
遵循以下结构:
- 概述 — 用1-2段文字介绍功能是什么以及为什么需要它
- 基础用法 — 最简单的可用示例
- 详细说明 — 更深入的解释及更多示例
- 边缘情况 — 高级模式、注意事项
- 相关链接 — 相关文档和示例
4. Use MDX components
4. 使用MDX组件
API links
API链接
Use or for API references:
[ClassName](?)[ClassName#methodName](?)markdown
The [Editor](?) class has many methods. Use [Editor#createShapes](?) to create shapes.使用或格式添加API引用:
[ClassName](?)[ClassName#methodName](?)markdown
The [Editor](?) class has many methods. Use [Editor#createShapes](?) to create shapes.Code highlighting
代码高亮
Use to highlight specific lines:
<FocusLines>markdown
<FocusLines lines={[2,6,10]}>
\`\`\`tsx
import { Tldraw } from 'tldraw'
import { useSyncDemo } from '@tldraw/sync'
\`\`\`
</FocusLines>使用组件高亮特定行:
<FocusLines>markdown
<FocusLines lines={[2,6,10]}>
\`\`\`tsx
import { Tldraw } from 'tldraw'
import { useSyncDemo } from '@tldraw/sync'
\`\`\`
</FocusLines>Images
图片
markdown
<Image
src="/images/api/events.png"
alt="A diagram showing an event being sent to the editor."
title="Caption text here."
/>markdown
<Image
src="/images/api/events.png"
alt="A diagram showing an event being sent to the editor."
title="Caption text here."
/>Tables for API documentation
API文档表格
Use tables for listing methods, options, or properties:
markdown
| Method | Description |
| ------------------------ | ---------------------------------------------- |
| [Editor#screenToPage](?) | Convert a point in screen space to page space. |
| [Editor#pageToScreen](?) | Convert a point in page space to screen space. |markdown
| Value | Description |
| --------- | ---------------------------------------------------- |
| `default` | Sets the initial zoom to 100%. |
| `fit-x` | The x axis will completely fill the viewport bounds. |使用表格列出方法、选项或属性:
markdown
| Method | Description |
| ------------------------ | ---------------------------------------------- |
| [Editor#screenToPage](?) | Convert a point in screen space to page space. |
| [Editor#pageToScreen](?) | Convert a point in page space to screen space. |markdown
| Value | Description |
| --------- | ---------------------------------------------------- |
| `default` | Sets the initial zoom to 100%. |
| `fit-x` | The x axis will completely fill the viewport bounds. |5. Verify
5. 验证
Check that:
- Code examples actually work
- API links resolve correctly
- Images have alt text
- Headings use sentence case
- No AI tells (see style guide)
检查以下内容:
- 代码示例可正常运行
- API链接可正确跳转
- 图片包含替代文本
- 标题使用句首大写格式
- 无AI生成痕迹(请参考风格指南)
References
参考资料
- Style guide: See for voice, tone, and formatting conventions.
../shared/docs-guide.md
- 风格指南:请查看获取语气、语调及格式规范。
../shared/docs-guide.md