reference-docs
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseReference Documentation Patterns
参考文档模式
Reference documentation is information-oriented - helping experienced users find precise technical details quickly. This skill provides patterns for writing clear, scannable reference pages.
Dependency: Always use this skill in conjunction with for core writing principles.
docs-style参考文档以信息传递为核心——帮助有经验的用户快速找到精准的技术细节。本技能提供了编写清晰、易扫描的参考页面的模式。
依赖项: 请始终结合技能使用,以遵循核心写作原则。
docs-stylePurpose and Audience
目标与受众
- Who: Experienced users seeking specific information
- Goal: Quick lookup of technical details
- Mode: Not for learning, for looking up
- Expectation: Brevity, consistency, completeness
- 适用人群: 有经验的、需要特定信息的用户
- 目标: 快速查找技术细节
- 使用场景: 用于查阅,而非学习
- 要求: 简洁、一致、完整
Document Structure Template
文档结构模板
Use this template when creating reference documentation:
markdown
---
title: "[Symbol/API Name]"
description: "One-line description of what it does"
---创建参考文档时可使用以下模板:
markdown
---
title: "[Symbol/API Name]"
description: "One-line description of what it does"
---[Name]
[Name]
Brief description (1-2 sentences). State what it is and its primary purpose.
Brief description (1-2 sentences). State what it is and its primary purpose.
Parameters
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| | Yes | What this parameter controls |
| | No | Optional behavior modification. Default: |
| Name | Type | Required | Description |
|---|---|---|---|
| | Yes | What this parameter controls |
| | No | Optional behavior modification. Default: |
Returns
Returns
| Type | Description |
|---|---|
| What the function returns and when |
| Type | Description |
|---|---|
| What the function returns and when |
Example
Example
language
import { symbolName } from 'package';
// Complete, runnable example showing common use case
const result = symbolName({
param1: 'realistic-value',
param2: 42
});
console.log(result);
// Expected output: { ... }language
import { symbolName } from 'package';
// Complete, runnable example showing common use case
const result = symbolName({
param1: 'realistic-value',
param2: 42
});
console.log(result);
// Expected output: { ... }Related
Related
- RelatedSymbol - Brief description
- AnotherSymbol - Brief description
undefined- RelatedSymbol - Brief description
- AnotherSymbol - Brief description
undefinedWriting Principles
写作原则
Brevity Over Explanation
简洁优先,避免冗余解释
- State facts, not rationale
- Avoid "why" - save that for Explanation docs
- Cut unnecessary words
Do:
markdown
Returns the user's display name.Avoid:
markdown
This function is useful when you need to get the user's display name
because it handles all the edge cases for you automatically.- 陈述事实,而非理由
- 避免解释“为什么”——这类内容放在说明文档中
- 删除冗余表述
正确示例:
markdown
Returns the user's display name.错误示例:
markdown
This function is useful when you need to get the user's display name
because it handles all the edge cases for you automatically.Scannable Tables, Not Prose
使用易扫描的表格,而非大段文字
Do:
markdown
| Name | Type | Description |
|------|------|-------------|
| `userId` | `string` | Unique user identifier |
| `options` | `Options` | Configuration object |Avoid:
markdown
The first parameter is `userId`, which should be a string containing
the unique user identifier. The second parameter is `options`, which
is an Options object containing the configuration.正确示例:
markdown
| Name | Type | Description |
|------|------|-------------|
| `userId` | `string` | Unique user identifier |
| `options` | `Options` | Configuration object |错误示例:
markdown
The first parameter is `userId`, which should be a string containing
the unique user identifier. The second parameter is `options`, which
is an Options object containing the configuration.Consistent Format Across Entries
保持条目格式一致
All reference pages for similar items should follow identical structure:
- Same heading order
- Same table columns
- Same code example format
- Same related links section
同类参考页面需遵循完全一致的结构:
- 相同的标题顺序
- 相同的表格列
- 相同的代码示例格式
- 相同的相关链接板块
Every Example Must Be Runnable
所有示例必须可运行
- Include all imports
- Show complete, working code
- Use realistic values (not "foo", "bar", "test123")
- Include expected output when helpful
- 包含所有必要的导入语句
- 展示完整、可运行的代码
- 使用真实合理的取值(而非"foo"、"bar"、"test123")
- 必要时标注预期输出
Code Example Patterns
代码示例模式
Show Common Use Case First
优先展示常用场景
markdown
undefinedmarkdown
undefinedExample
Example
Basic Usage
Basic Usage
typescript
const user = await getUser('user-123');
console.log(user.name);typescript
const user = await getUser('user-123');
console.log(user.name);With Options
With Options
typescript
const user = await getUser('user-123', {
includeMetadata: true,
fields: ['name', 'email', 'role']
});undefinedtypescript
const user = await getUser('user-123', {
includeMetadata: true,
fields: ['name', 'email', 'role']
});undefinedInclude Setup and Context
包含初始化与上下文
markdown
```typescript
import { Client } from '@example/sdk';
// Initialize client (required once per application)
const client = new Client({ apiKey: process.env.API_KEY });
// Now use the function
const result = await client.users.list();undefinedmarkdown
```typescript
import { Client } from '@example/sdk';
// Initialize client (required once per application)
const client = new Client({ apiKey: process.env.API_KEY });
// Now use the function
const result = await client.users.list();undefinedUse Realistic Values
使用真实合理的取值
Do:
Avoid:
userId: 'usr_a1b2c3d4'userId: 'foo'Do:
Avoid:
email: 'jane.smith@company.com'email: 'test@test.com'正确示例:
错误示例:
userId: 'usr_a1b2c3d4'userId: 'foo'正确示例:
错误示例:
email: 'jane.smith@company.com'email: 'test@test.com'Parameter Documentation Patterns
参数文档模式
Required vs Optional
必填与可选参数
Clearly indicate which parameters are required:
markdown
| Name | Type | Required | Default | Description |
|------|------|----------|---------|-------------|
| `apiKey` | `string` | Yes | - | Your API key |
| `timeout` | `number` | No | `30000` | Request timeout in ms |
| `retries` | `number` | No | `3` | Number of retry attempts |清晰标注哪些参数是必填项:
markdown
| Name | Type | Required | Default | Description |
|------|------|----------|---------|-------------|
| `apiKey` | `string` | Yes | - | Your API key |
| `timeout` | `number` | No | `30000` | Request timeout in ms |
| `retries` | `number` | No | `3` | Number of retry attempts |Complex Types
复杂类型
For object parameters, document the shape:
markdown
undefined对于对象类型的参数,需说明其结构:
markdown
undefinedParameters
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| | No | Configuration options |
| Name | Type | Required | Description |
|---|---|---|---|
| | No | Configuration options |
UserOptions
UserOptions
| Property | Type | Required | Description |
|---|---|---|---|
| | No | Include soft-deleted users |
| | No | Fields to return |
| | No | Maximum results (default: 100) |
undefined| Property | Type | Required | Description |
|---|---|---|---|
| | No | Include soft-deleted users |
| | No | Fields to return |
| | No | Maximum results (default: 100) |
undefinedEnum Values
枚举值
Document allowed values clearly:
markdown
| Name | Type | Values | Description |
|------|------|--------|-------------|
| `status` | `string` | `active`, `pending`, `suspended` | User account status |清晰说明允许的取值:
markdown
| Name | Type | Values | Description |
|------|------|--------|-------------|
| `status` | `string` | `active`, `pending`, `suspended` | User account status |Return Value Documentation
返回值文档
Simple Returns
简单返回值
markdown
undefinedmarkdown
undefinedReturns
Returns
UsernullundefinedUsernullundefinedComplex Returns
复杂返回值
markdown
undefinedmarkdown
undefinedReturns
Returns
| Property | Type | Description |
|---|---|---|
| | Array of user objects |
| | Pagination metadata |
| | Total matching records |
undefined| Property | Type | Description |
|---|---|---|
| | Array of user objects |
| | Pagination metadata |
| | Total matching records |
undefinedError Conditions
错误场景
markdown
undefinedmarkdown
undefinedErrors
Errors
| Error | Condition |
|---|---|
| User does not exist |
| Invalid or expired API key |
| Too many requests |
undefined| Error | Condition |
|---|---|
| User does not exist |
| Invalid or expired API key |
| Too many requests |
undefinedAPI Reference Specifics
API参考文档细节
HTTP Endpoints
HTTP接口
markdown
undefinedmarkdown
undefinedEndpoint
Endpoint
http
GET /api/v1/users/{userId}http
GET /api/v1/users/{userId}Path Parameters
Path Parameters
| Name | Type | Description |
|---|---|---|
| | The user's unique identifier |
| Name | Type | Description |
|---|---|---|
| | The user's unique identifier |
Query Parameters
Query Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| | No | Comma-separated list of fields |
| Name | Type | Required | Description |
|---|---|---|---|
| | No | Comma-separated list of fields |
Headers
Headers
| Name | Required | Description |
|---|---|---|
| Yes | Bearer token |
| No | Request tracking ID |
| Name | Required | Description |
|---|---|---|
| Yes | Bearer token |
| No | Request tracking ID |
Response
Response
json
{
"id": "usr_a1b2c3d4",
"name": "Jane Smith",
"email": "jane@company.com"
}undefinedjson
{
"id": "usr_a1b2c3d4",
"name": "Jane Smith",
"email": "jane@company.com"
}undefinedComponent/Props Reference
组件/属性参考文档
For UI components:
markdown
undefined针对UI组件:
markdown
undefinedProps
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| | | Visual style |
| | | Button size |
| | | Disable interactions |
| | - | Click handler |
| Prop | Type | Default | Description |
|---|---|---|---|
| | | Visual style |
| | | Button size |
| | | Disable interactions |
| | - | Click handler |
Slots
Slots
| Name | Description |
|---|---|
| Button content |
| Icon to display before text |
undefined| Name | Description |
|---|---|
| Button content |
| Icon to display before text |
undefinedRelated Links Section
相关链接板块
Always include links to related content:
markdown
undefined请始终包含相关内容的链接:
markdown
undefinedRelated
Related
- createUser - Create a new user
- updateUser - Modify user properties
- deleteUser - Remove a user
- User Authentication Guide - How authentication works
undefined- createUser - Create a new user
- updateUser - Modify user properties
- deleteUser - Remove a user
- User Authentication Guide - How authentication works
undefinedChecklist for Reference Pages
参考页面检查清单
Before considering a reference page complete:
- Title matches the symbol/API name exactly
- Description is one clear sentence
- All parameters documented with types
- Required vs optional clearly marked
- Default values specified for optional parameters
- Return type and structure documented
- At least one complete, runnable example
- Example uses realistic values
- Related pages linked
- Format matches other reference pages in the docs
参考页面完成前,请确认以下事项:
- 标题与符号/API名称完全一致
- 描述为清晰的单句
- 所有参数均已标注类型
- 必填与可选参数已清晰区分
- 可选参数已说明默认值
- 返回值类型与结构已文档化
- 至少包含一个完整、可运行的示例
- 示例使用了真实合理的取值
- 已链接相关页面
- 格式与文档集中其他参考页面一致