Documentation Generator
Generate various types of documentation from code analysis.
Arguments
- •
$0: Documentation type -api,readme,claude,setup,all(required) - •
$1: Output path (optional - defaults to appropriate location)
Documentation Types
1. API Documentation (api)
Generate API endpoint documentation from code.
FastAPI Projects:
bash
# FastAPI has built-in OpenAPI generation curl http://localhost:8000/openapi.json > docs/openapi.json # Or extract from code grep -rn "@router\.\|@app\." --include="*.py" app/routes/
Template:
markdown
# API Documentation
## Base URL
`http://localhost:8000/v1`
## Authentication
All endpoints require JWT token in Authorization header:
`Authorization: Bearer <token>`
## Endpoints
### [Resource Name]
#### GET /resource
**Description:** Get list of resources
**Auth Required:** Yes
**Roles:** admin, staff
**Query Parameters:**
| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| limit | int | No | Max items (default: 100) |
| offset | int | No | Skip items (default: 0) |
**Response:**
```json
{
"items": [],
"total": 0
}
code
**Next.js API Routes:** ```bash # Find all API routes find app/api -name "route.ts" -o -name "route.js"
2. README Documentation (readme)
Generate or update README.md sections.
Template:
markdown
# Project Name ## Overview [Auto-generated from package.json/pyproject.toml description] ## Tech Stack - **Framework:** [Detected framework] - **Database:** [Detected database] - **Testing:** [Detected test framework] ## Prerequisites - Node.js >= 18 / Python >= 3.12 - [Database] installed and running - Environment variables configured ## Quick Start ### Installation ```bash [Package manager] install
Development
bash
[Start command]
Testing
bash
[Test command]
Project Structure
code
[Auto-generated directory tree]
Environment Variables
See .env.example for required variables.
API Documentation
See docs/api.md for API reference.
Contributing
[Standard contributing guidelines]
License
[License from package.json/pyproject.toml]
code
### 3. CLAUDE.md Documentation (`claude`) Generate context file for Claude Code. **Template:** ```markdown # [Project Name] ## Project Overview [Brief description of the project] ## Tech Stack - **Language:** [Python/TypeScript] - **Framework:** [FastAPI/Next.js/etc] - **Database:** [MongoDB/PostgreSQL] - **Package Manager:** [npm/pnpm/uv] ## Development Commands ### Start Development Server ```bash [Start command]
Run Tests
bash
[Test command]
Lint & Format
bash
[Lint command]
Build
bash
[Build command]
Project Structure
code
[Directory tree of important folders]
Key Files
- •
[config file]- [Description] - •
[main entry]- [Description]
Environment Variables
Required variables (see .env.example):
- •
VAR_NAME- [Description]
Testing Strategy
- •Unit tests:
[path] - •Integration tests:
[path] - •E2E tests:
[path]
API Patterns
[Key patterns used in the codebase]
Common Issues
- •[Issue]: [Solution]
Important Instructions
- •[Key instruction 1]
- •[Key instruction 2]
code
### 4. Setup Guide (`setup`) Generate detailed setup instructions. **Template:** ```markdown # Setup Guide ## Prerequisites ### Required Software - [ ] [Runtime] version X.X+ - [ ] [Database] version X.X+ - [ ] [Package manager] ### Verify Installation ```bash [version check commands]
Installation Steps
1. Clone Repository
bash
git clone [repo-url] cd [project-name]
2. Install Dependencies
bash
[install command]
3. Configure Environment
bash
cp .env.example .env.local # Edit .env.local with your settings
4. Setup Database
bash
[database setup commands]
5. Run Migrations
bash
[migration command]
6. Seed Data (Optional)
bash
[seed command]
7. Start Development Server
bash
[start command]
8. Verify Setup
Open http://localhost:[port] in your browser.
Troubleshooting
Common Issues
[Issue 1]
Symptom: [Description] Solution: [Fix]
[Issue 2]
Symptom: [Description] Solution: [Fix]
code
## Generation Process
### 1. Analyze Project
```bash
# Detect project type
if [ -f "pyproject.toml" ]; then
PROJECT_TYPE="python"
elif [ -f "package.json" ]; then
PROJECT_TYPE="node"
fi
# Extract metadata
# Python: pyproject.toml
# Node: package.json
# Find key files
ls -la
find . -name "*.md" -maxdepth 2
2. Extract Information
From package.json:
- •name, description, version
- •scripts (start, test, build)
- •dependencies, devDependencies
From pyproject.toml:
- •name, description, version
- •dependencies
- •scripts/commands
From code:
- •Route definitions
- •Model definitions
- •Configuration patterns
3. Generate Output
Write documentation to appropriate location:
- •API docs →
docs/api.md - •README →
README.md - •CLAUDE.md →
CLAUDE.md - •Setup →
docs/setup.md
Output Format
code
Documentation Generation: [project-name] Type: [api/readme/claude/setup/all] Analyzing project... Project type: [type] Framework: [framework] Database: [database] Extracting information... Routes found: X Models found: Y Config files: Z Generating documentation... Writing: [output-path] Documentation generated successfully! Files created: - [file1] - [file2]