AgentSkillsCN

generate

从代码中自动生成文档——提取类型、注释与函数签名,打造API文档、README文件以及参考文档。重点在于产出实用且可操作性强的文档。 适用场景如下:“生成文档”、“创建文档”、“为API撰写文档”、“生成README”、“从代码中生成文档”。

SKILL.md
--- frontmatter
name: generate
description: |
  Generate documentation from code - extract types, comments, and signatures to create
  API docs, README files, and reference documentation. Focus on useful, actionable docs.

  Use when: "generate docs", "create documentation", "document the API",
  "generate README", "make docs from code"

Generate Documentation Skill

Create useful documentation from code - extract information and present it clearly.

Purpose

Transform code into documentation:

  • Extract types, signatures, and comments
  • Generate API documentation
  • Create/update README files
  • Discover and use documentation tools

Commands

CommandPurpose
/wicked-engineering:generate [path]Generate docs from code
/wicked-engineering:generate --apiGenerate API documentation
/wicked-engineering:generate --readmeGenerate/update README
/wicked-engineering:generate --typesGenerate type documentation

Quick Start

bash
# Generate general documentation
/wicked-engineering:generate src/

# Generate API documentation
/wicked-engineering:generate src/api --api

# Update README
/wicked-engineering:generate --readme

Process

1. Analyze Target

Understand what to document:

  • Language and framework
  • Code structure (functions, classes, modules)
  • Existing comments and docstrings
  • Type information

2. Discover Tools

Check for documentation tooling:

  • JavaScript/TypeScript: TypeDoc, JSDoc, Docusaurus
  • Python: Sphinx, MkDocs, pdoc
  • Rust: rustdoc, Go: godoc

If tools exist, use them. Otherwise extract manually.

3. Extract Information

From code, extract:

  • Function signatures and descriptions
  • Class structure and methods
  • API endpoints and schemas
  • Type definitions

4. Generate Documentation

Create focused, useful docs:

  • README: overview, installation, quick start
  • API docs: endpoints, parameters, responses
  • Reference: functions, classes, types

See Templates for standard formats.

Language Patterns

Extract from:

  • JavaScript/TypeScript: JSDoc comments and type definitions
  • Python: Docstrings and type hints
  • REST APIs: Route definitions and schemas
  • Other: Language-specific doc comments

Tool Integration

Check for existing doc tools (TypeDoc, Sphinx, rustdoc) and use them. If none exist, extract and generate manually.

Read project metadata from package.json or pyproject.toml for README generation.

Best Practices

  1. Include Examples - Every function/endpoint needs an example
  2. Use Type Information - Show parameter types clearly
  3. Document Edge Cases - Note unusual behavior
  4. Don't Generate Boilerplate - Focus on useful content
  5. Update, Don't Replace - Preserve manual sections

Integration

Use wicked-search to find code to document. Use wicked-mem to learn and maintain project doc style.

Events

  • [docs:generated:success] - Documentation created
  • [docs:readme:updated:success] - README updated
  • [docs:api:generated:success] - API docs generated

Tips

  1. Use Existing Tools - Don't reinvent TypeDoc/Sphinx
  2. Parse, Don't Guess - Read actual code structure
  3. Include Examples - Show real usage
  4. Extract from Tests - Tests are usage examples
  5. Link Related Docs - Cross-reference related APIs
  6. Update, Don't Replace - Preserve manual sections

Reference

  • Templates - Standard documentation templates