name: documentation-writer description: 生成全面的文档,包括README文件、API文档、代码注释(JSDoc、docstrings、XML)和架构文档。 metadata: short-description: 生成项目文档
文档编写技能
描述
为代码、API和项目生成全面的文档。
触发条件
/docs命令- 用户请求文档
- 用户需要README或API文档
提示
您是一位技术文档撰写者,能够创建清晰、全面的文档。
README模板
# 项目名称
简要描述该项目的作用。
## 功能特性
- ✅ 功能1
- ✅ 功能2
- 🚧 功能3(开发中)
## 快速开始
```bash
# 克隆仓库
git clone https://github.com/user/project.git
cd project
# 安装依赖
npm install
# 启动开发服务器
npm run dev
安装
前置要求
- Node.js >= 18
- PostgreSQL >= 14
环境变量
DATABASE_URL=postgresql://user:pass@localhost:5432/db
JWT_SECRET=your-secret-key
使用示例
import { Client } from 'my-library';
const client = new Client({ apiKey: 'xxx' });
const result = await client.doSomething();
API参考
client.createUser(data)
创建新用户。
| 参数 | 类型 | 必填 | 描述 |
|---|---|---|---|
| string | 是 | 用户邮箱 | |
| name | string | 是 | 用户姓名 |
返回: Promise<User>
贡献指南
- Fork仓库
- 创建功能分支 (
git checkout -b feature/amazing) - 提交更改 (
git commit -m 'feat: add amazing feature') - 推送到分支 (
git push origin feature/amazing) - 发起Pull Request
许可证
MIT © [您的姓名]
### JSDoc注释
```typescript
/**
* 在系统中创建新用户。
*
* @param {CreateUserDto} data - 用户创建数据
* @param {string} data.email - 用户邮箱地址(必须唯一)
* @param {string} data.name - 用户显示名称
* @param {string} [data.avatar] - 可选头像URL
* @returns {Promise<User>} 创建的用户对象
* @throws {ValidationError} 邮箱格式无效时抛出
* @throws {DuplicateError} 邮箱已存在时抛出
*
* @example
* const user = await userService.createUser({
* email: 'john@example.com',
* name: 'John Doe'
* });
*/
async createUser(data: CreateUserDto): Promise<User> {
// 实现代码
}
C# XML文档
/// <summary>
/// 在系统中创建新用户。
/// </summary>
/// <param name="data">用户创建数据。</param>
/// <returns>创建的用户对象。</returns>
/// <exception cref="ValidationException">邮箱格式无效时抛出。</exception>
/// <exception cref="DuplicateException">邮箱已存在时抛出。</exception>
/// <example>
/// <code>
/// var user = await userService.CreateUserAsync(new CreateUserDto
/// {
/// Email = "john@example.com",
/// Name = "John Doe"
/// });
/// </code>
/// </example>
public async Task<User> CreateUserAsync(CreateUserDto data)
{
// 实现代码
}
标签
文档编写, readme, api文档, 代码注释, 技术写作
兼容性
- Codex: ✅
- Claude Code: ✅