中文技术文档写作规范
Chinese Technical Documentation Writing Guidelines
中文技术文档最常见的问题不是内容不够,而是读起来别扭——中英文挤在一起没有空格、全角半角混用、一股机翻味。本技能提供一套完整的中文技术文档写作规范,让你的文档专业、好读、不出戏。
核心原则: 排版服务于阅读体验,规范服务于一致性,内容服务于读者。
The most common problem with Chinese technical documentation isn't insufficient content, but awkward readability—no spaces between Chinese and English characters, mixed full-width and half-width characters, and a strong machine translation vibe. This skill provides a complete set of Chinese technical documentation writing guidelines to make your documents professional, easy to read, and natural.
Core Principles: Formatting serves reading experience, standards serve consistency, and content serves readers.
中文排版规范
Chinese Formatting Standards
Add spaces between Chinese and English:
使用 Git 进行版本管理,配合 Jenkins 实现持续集成。
使用 Git 进行版本管理,配合 Jenkins 实现持续集成。
使用Git进行版本管理,配合Jenkins实现持续集成。
使用Git进行版本管理,配合Jenkins实现持续集成。
**Add spaces between Chinese and numbers:**
本次更新包含 3 个新功能和 12 个 Bug 修复。
本次更新包含 3 个新功能和 12 个 Bug 修复。
本次更新包含3个新功能和12个Bug修复。
**Add spaces between numbers and units:**
文件大小不超过 5 MB,响应时间控制在 200 ms 以内。
文件大小不超过 5 MB,响应时间控制在 200 ms 以内。
文件大小不超过5MB,响应时间控制在200ms以内。
文件大小不超过5MB,响应时间控制在200ms以内。
**Exceptions:** No spaces for degrees, percentages, etc.:
今天气温 32 °C,CPU 使用率 95 %。
**Add spaces around links:**
Use full-width punctuation in Chinese context:
注意:该接口需要鉴权,请先获取 Token.
**No spaces between full-width punctuation and English/numbers:**
项目使用 MIT 协议,详见 LICENSE 文件。
项目使用 MIT 协议,详见 LICENSE 文件。
项目使用 MIT 协议 ,详见 LICENSE 文件 。
项目使用 MIT 协议 ,详见 LICENSE 文件 。
**Usage of parentheses:**
中文语境用全角括号
Use full-width parentheses in Chinese context
括号内有英文或数字时用半角括号
Use half-width parentheses when containing English or numbers
该项目基于 Spring Boot (v3.2.0) 开发。
该项目基于 Spring Boot (v3.2.0) 开发。
纯英文内容用半角括号
Use half-width parentheses for pure English content
See the documentation (README.md) for details.
See the documentation (README.md) for details.
**Usage of quotation marks:**
中文使用直角引号(推荐)
Use right-angle quotation marks for Chinese (recommended)
也可以使用弯引号(视团队规范而定)
Curved quotation marks are also acceptable (subject to team standards)
嵌套引号
Nested quotation marks
阿拉伯数字(技术文档中统一使用半角数字)
Arabic numerals (use half-width numerals uniformly in technical documentation)
不要用中文数字写技术参数
Do not use Chinese numerals for technical parameters
坏:支持最多一百个并发连接。
Bad: 支持最多一百个并发连接。
数字使用半角字符
Use half-width characters for numbers
版本号 v2.1.0,端口号 8080,HTTP 状态码 200。
版本号 v2.1.0,端口号 8080,HTTP 状态码 200。
中英混排最佳实践
Best Practices for Mixed Chinese-English Layout
术语处理原则
Terminology Handling Principles
保留英文的情况:
- 专有名词:React、Kubernetes、Redis、MySQL
- 行业通用缩写:API、SDK、CLI、ORM、CI/CD
- 命令和代码:、
- 协议和标准:HTTP、TCP/IP、JSON、REST
- 没有公认中文翻译的术语:debounce、throttle、middleware
翻译为中文的情况:
- 有公认翻译的通用概念:数据库、服务器、浏览器、框架
- 描述性短语:version control → 版本控制,load balancing → 负载均衡
- 文档标题和章节名(尽量中文,技术名词可保留英文)
Cases where English should be retained:
- Proper nouns: React, Kubernetes, Redis, MySQL
- Industry通用缩写:API, SDK, CLI, ORM, CI/CD
- Commands and code: ,
- Protocols and standards: HTTP, TCP/IP, JSON, REST
- Terms without widely accepted Chinese translations: debounce, throttle, middleware
Cases where translation to Chinese is required:
- General concepts with widely accepted translations: 数据库 (database), 服务器 (server), 浏览器 (browser), 框架 (framework)
- Descriptive phrases: version control → 版本控制, load balancing → 负载均衡
- Document titles and section names (preferably in Chinese, technical terms can be retained in English)
首次出现标注翻译
Add Chinese-English annotations on first occurrence
Add Chinese-English annotations when technical terms appear for the first time:
本系统采用消息队列(Message Queue)实现异步通信,
使用死信队列(Dead Letter Queue)处理消费失败的消息。
本系统采用消息队列(Message Queue)实现异步通信,
使用死信队列(Dead Letter Queue)处理消费失败的消息。
后续出现直接使用
Use directly in subsequent occurrences
避免过度翻译
Avoid over-translation
好:保留业界通用英文术语
Good: Retain industry-standard English terms
在 Controller 层做参数校验,Service 层处理业务逻辑。
在 Controller 层做参数校验,Service 层处理业务逻辑。
坏:强行翻译反而看不懂
Bad: Forced translation makes it hard to understand
API 文档中英对照格式
Chinese-English Format for API Documentation
接口文档模板
API Documentation Template
创建订单 / Create Order
创建订单 / Create Order
- 请求方式 (Method): POST
- 请求路径 (Path):
- 鉴权方式 (Auth): Bearer Token
- Content-Type: application/json
- 请求方式 (Method): POST
- 请求路径 (Path):
- 鉴权方式 (Auth): Bearer Token
- Content-Type: application/json
请求参数 (Request Parameters)
请求参数 (Request Parameters)
| 参数名 (Field) | 类型 (Type) | 必填 (Required) | 说明 (Description) |
|---|
| product_id | string | 是 | 商品 ID (Product ID) |
| quantity | integer | 是 | 购买数量 (Quantity),最小值为 1 |
| address_id | string | 是 | 收货地址 ID (Shipping address ID) |
| coupon_code | string | 否 | 优惠券码 (Coupon code) |
| 参数名 (Field) | 类型 (Type) | 必填 (Required) | 说明 (Description) |
|---|
| product_id | string | 是 | 商品 ID (Product ID) |
| quantity | integer | 是 | 购买数量 (Quantity),最小值为 1 |
| address_id | string | 是 | 收货地址 ID (Shipping address ID) |
| coupon_code | string | 否 | 优惠券码 (Coupon code) |
请求示例 (Request Example)
请求示例 (Request Example)
```json
{
"product_id": "prod_abc123",
"quantity": 2,
"address_id": "addr_xyz789",
"coupon_code": "SUMMER2024"
}
```
```json
{
"product_id": "prod_abc123",
"quantity": 2,
"address_id": "addr_xyz789",
"coupon_code": "SUMMER2024"
}
```
响应参数 (Response Parameters)
响应参数 (Response Parameters)
| 参数名 (Field) | 类型 (Type) | 说明 (Description) |
|---|
| order_id | string | 订单 ID (Order ID) |
| status | string | 订单状态 (Order status): pending / paid / shipped |
| total_amount | integer | 订单总金额,单位:分 (Total amount in cents) |
| created_at | string | 创建时间 (Created at),ISO 8601 格式 |
| 参数名 (Field) | 类型 (Type) | 说明 (Description) |
|---|
| order_id | string | 订单 ID (Order ID) |
| status | string | 订单状态 (Order status): pending / paid / shipped |
| total_amount | integer | 订单总金额,单位:分 (Total amount in cents) |
| created_at | string | 创建时间 (Created at),ISO 8601 格式 |
响应示例 (Response Example)
响应示例 (Response Example)
```json
{
"code": 0,
"message": "success",
"data": {
"order_id": "ord_20240315001",
"status": "pending",
"total_amount": 9900,
"created_at": "2024-03-15T10:30:00+08:00"
}
}
```
```json
{
"code": 0,
"message": "success",
"data": {
"order_id": "ord_20240315001",
"status": "pending",
"total_amount": 9900,
"created_at": "2024-03-15T10:30:00+08:00"
}
}
```
错误码 (Error Codes)
错误码 (Error Codes)
| 错误码 (Code) | 说明 (Description) | 处理建议 (Suggestion) |
|---|
| 40001 | 商品不存在 (Product not found) | 检查 product_id 是否正确 |
| 40002 | 库存不足 (Insufficient stock) | 减少购买数量或稍后重试 |
| 40003 | 优惠券已过期 (Coupon expired) | 移除 coupon_code 或更换优惠券 |
| 错误码 (Code) | 说明 (Description) | 处理建议 (Suggestion) |
|---|
| 40001 | 商品不存在 (Product not found) | 检查 product_id 是否正确 |
| 40002 | 库存不足 (Insufficient stock) | 减少购买数量或稍后重试 |
| 40003 | 优惠券已过期 (Coupon expired) | 移除 coupon_code 或更换优惠券 |
金额表示约定
Convention for Amount Representation
好:明确说明单位
Good: Clearly specify the unit
total_amount: 9900 // 单位:分(即 99.00 元)
total_amount: 9900 // 单位:分(即 99.00 元)
坏:不说明单位,造成歧义
Bad: No unit specified, causing ambiguity
total_amount: 99.00 // 是元还是分?浮点数会有精度问题
total_amount: 99.00 // Is it yuan or cents? Floating-point numbers have precision issues
README.md 中文模板
Chinese README.md Template
Common README structure for domestic open-source projects:
- 特性一:简要描述
- 特性二:简要描述
- 特性三:简要描述
- 特性一:简要描述
- 特性二:简要描述
- 特性三:简要描述
- Node.js >= 20
- MySQL >= 8.0
- Node.js >= 20
- MySQL >= 8.0
```bash
npm install your-package
```
```bash
npm install your-package
```
```typescript
import { YourPackage } from 'your-package';
const client = new YourPackage({ apiKey: 'your-key' });
const result = await client.doSomething();
```
```typescript
import { YourPackage } from 'your-package';
const client = new YourPackage({ apiKey: 'your-key' });
const result = await client.doSomething();
```
欢迎提交 Issue 和 Pull Request。请先阅读 贡献指南。
欢迎提交 Issue 和 Pull Request。请先阅读 贡献指南。
常见问题与避坑指南
Common Issues and Pitfall Avoidance Guide
问题一:机翻味
Issue 1: Machine Translation Vibe
Symptoms: Stiff sentence structure, inconsistent with Chinese expression habits.
这个函数被用来计算用户的折扣。如果你想要获取更多信息,请参考文档。
这个函数被用来计算用户的折扣。如果你想要获取更多信息,请参考文档。
这个函数用于计算用户折扣。更多信息请参考文档。
**要点:**
- 避免被动语态("被用来" → "用于")
- 避免冗余代词("你想要" → 直接说)
- 避免直译英文句式
这个函数用于计算用户折扣。更多信息请参考文档。
**Key Points:**
- Avoid passive voice ("被用来" → "用于")
- Avoid redundant pronouns ("你想要" → omit)
- Avoid literal translation of English sentence structures
问题二:句式欧化
Issue 2: Europeanized Sentence Structure
Symptoms: Long attributives, multiple clauses, overly long sentences.
这是一个可以帮助开发者在不需要手动配置复杂的构建工具链的情况下
快速搭建现代化前端项目的脚手架工具。
这是一个可以帮助开发者在不需要手动配置复杂的构建工具链的情况下
快速搭建现代化前端项目的脚手架工具。
这是一个前端脚手架工具,帮助开发者快速搭建项目,免去手动配置构建工具链的麻烦。
**要点:**
- 长句拆成短句
- 把定语从句改成并列句
- 一句话只说一件事
这是一个前端脚手架工具,帮助开发者快速搭建项目,免去手动配置构建工具链的麻烦。
**Key Points:**
- Split long sentences into short ones
- Convert attributive clauses to coordinate clauses
- Focus on one idea per sentence
问题三:过度翻译
Issue 3: Over-translation
请打开您的"终端模拟器",运行"节点包管理器"的安装命令。
请打开您的"终端模拟器",运行"节点包管理器"的安装命令。
问题四:中英标点混用
Issue 4: Mixed Chinese and English Punctuation
坏:中文句子用了英文逗号和句号
Bad: Chinese sentences using English commas and periods
好:中文句子用全角标点
Good: Chinese sentences using full-width punctuation
坏:英文内容用了中文标点
Bad: English content using Chinese punctuation
好:英文内容用半角标点
Good: English content using half-width punctuation
问题五:缺乏结构化
Issue 5: Lack of Structure
坏:一大段文字没有分段
Bad: A large block of text without segmentation
本系统使用 Redis 做缓存提高查询性能同时使用 MySQL 做持久化存储
数据写入时先写 MySQL 再异步更新 Redis 缓存读取时先查 Redis 如果
未命中再查 MySQL 并将结果回写缓存设置过期时间为 30 分钟……
本系统使用 Redis 做缓存提高查询性能同时使用 MySQL 做持久化存储
数据写入时先写 MySQL 再异步更新 Redis 缓存读取时先查 Redis 如果
未命中再查 MySQL 并将结果回写缓存设置过期时间为 30 分钟……
好:用列表和分段组织信息
Good: Organize information with lists and sections
本系统的缓存策略如下:
- 存储层: MySQL(持久化)+ Redis(缓存)
- 写入流程: 先写 MySQL,再异步更新 Redis
- 读取流程: 先查 Redis → 未命中则查 MySQL → 回写 Redis
- 缓存过期: TTL 设为 30 分钟
本系统的缓存策略如下:
- 存储层: MySQL(持久化)+ Redis(缓存)
- 写入流程: 先写 MySQL,再异步更新 Redis
- 读取流程: 先查 Redis → 未命中则查 MySQL → 回写 Redis
- 缓存过期: TTL 设为 30 分钟
Before publishing the document, check each item: