# Install from source
pip install git+https://github.com/AnhMinh-Le/CodeDocumentation.git
# Verify installation
codedocumentation --versioncodedocumentation supports multiple models via an OpenAI-compatible SDK layer.
codedocumentation config set \
--api-key YOUR_API_KEY \
--base-url https://api.anthropic.com \
--main-model claude-sonnet-4 \
--cluster-model claude-sonnet-4 \
--fallback-model glm-4p5# Navigate to your project
cd /path/to/your/project
# Generate documentation
codedocumentation generate
# Generate with HTML viewer for GitHub Pages
codedocumentation generate --github-pages --create-branchThat's it! Your documentation will be generated in ./docs/ with comprehensive repository-level analysis.
codedocumentation is an open-source framework for automated repository-level documentation across seven programming languages. It generates holistic, architecture-aware documentation that captures not only individual functions but also their cross-file, cross-module, and system-level interactions.
π Python β’ β Java β’ π¨ JavaScript β’ π· TypeScript β’ βοΈ C β’ π§ C++ β’ πͺ C#
# Set up your API configuration
codedocumentation config set \
--api-key <your-api-key> \
--base-url <provider-url> \
--main-model <model-name> \
--cluster-model <model-name> \
--fallback-model <model-name>
# Configure max token settings
codedocumentation config set --max-tokens 32768 --max-token-per-module 36369 --max-token-per-leaf-module 16000
# Configure max depth for hierarchical decomposition
codedocumentation config set --max-depth 3
# Show current configuration
codedocumentation config show
# Validate your configuration
codedocumentation config validate# Basic generation
codedocumentation generate
# Custom output directory
codedocumentation generate --output ./documentation
# Create git branch for documentation
codedocumentation generate --create-branch
# Generate HTML viewer for GitHub Pages
codedocumentation generate --github-pages
# Enable verbose logging
codedocumentation generate --verbose
# Full-featured generation
codedocumentation generate --create-branch --github-pages --verbosecodedocumentation supports customization for language-specific projects and documentation styles:
# C# project: only analyze .cs files, exclude test directories
codedocumentation generate --include "*.cs" --exclude "Tests,Specs,*.test.cs"
# Focus on specific modules with architecture-style docs
codedocumentation generate --focus "src/core,src/api" --doc-type architecture
# Add custom instructions for the AI agent
codedocumentation generate --instructions "Focus on public APIs and include usage examples"-
--include: When specified, ONLY these patterns are used (replaces defaults completely)- Example:
--include "*.cs"will analyze ONLY.csfiles - If omitted, all supported file types are analyzed
- Supports glob patterns:
*.py,src/**/*.ts,*.{js,jsx}
- Example:
-
--exclude: When specified, patterns are MERGED with default ignore patterns- Example:
--exclude "Tests,Specs"will exclude these directories AND still exclude.git,__pycache__,node_modules, etc. - Default patterns include:
.git,node_modules,__pycache__,*.pyc,bin/,dist/, and many more - Supports multiple formats:
- Exact names:
Tests,.env,config.local - Glob patterns:
*.test.js,*_test.py,*.min.* - Directory patterns:
build/,dist/,coverage/
- Exact names:
- Example:
Save your preferred settings as defaults:
# Set include patterns for C# projects
codedocumentation config agent --include "*.cs"
# Exclude test projects by default (merged with default excludes)
codedocumentation config agent --exclude "Tests,Specs,*.test.cs"
# Set focus modules
codedocumentation config agent --focus "src/core,src/api"
# Set default documentation type
codedocumentation config agent --doc-type architecture
# View current agent settings
codedocumentation config agent
# Clear all agent settings
codedocumentation config agent --clear| Option | Description | Behavior | Example |
|---|---|---|---|
--include |
File patterns to include | Replaces defaults | *.cs, *.py, src/**/*.ts |
--exclude |
Patterns to exclude | Merges with defaults | Tests,Specs, *.test.js, build/ |
--focus |
Modules to document in detail | Standalone option | src/core,src/api |
--doc-type |
Documentation style | Standalone option | api, architecture, user-guide, developer |
--instructions |
Custom agent instructions | Standalone option | Free-form text |
codedocumentation allows you to configure maximum token limits for LLM calls. This is useful for:
- Adapting to different model context windows
- Controlling costs by limiting response sizes
- Optimizing for faster response times
# Set max tokens for LLM responses (default: 32768)
codedocumentation config set --max-tokens 16384
# Set max tokens for module clustering (default: 36369)
codedocumentation config set --max-token-per-module 40000
# Set max tokens for leaf modules (default: 16000)
codedocumentation config set --max-token-per-leaf-module 20000
# Set max depth for hierarchical decomposition (default: 2)
codedocumentation config set --max-depth 3
# Override at runtime for a single generation
codedocumentation generate --max-tokens 16384 --max-token-per-module 40000 --max-depth 3| Option | Description | Default |
|---|---|---|
--max-tokens |
Maximum output tokens for LLM response | 32768 |
--max-token-per-module |
Input tokens threshold for module clustering | 36369 |
--max-token-per-leaf-module |
Input tokens threshold for leaf modules | 16000 |
--max-depth |
Maximum depth for hierarchical decomposition | 2 |
- API keys: Securely stored in system keychain (macOS Keychain, Windows Credential Manager, Linux Secret Service)
- Settings & Agent Instructions:
~/.codedocumentation/config.json
Generated documentation includes both textual descriptions and visual artifacts for comprehensive understanding.
- Repository overview with architecture guide
- Module-level documentation with API references
- Usage examples and implementation patterns
- Cross-module interaction analysis
- System architecture diagrams (Mermaid)
- Data flow visualizations
- Dependency graphs and module relationships
- Sequence diagrams for complex interactions
./docs/
βββ overview.md # Repository overview (start here!)
βββ module1.md # Module documentation
βββ module2.md # Additional modules...
βββ module_tree.json # Hierarchical module structure
βββ first_module_tree.json # Initial clustering result
βββ metadata.json # Generation metadata
βββ index.html # Interactive viewer (with --github-pages)
codedocumentation employs a three-stage process for comprehensive documentation generation:
-
Hierarchical Decomposition: Uses dynamic programming-inspired algorithms to partition repositories into coherent modules while preserving architectural context across multiple granularity levels.
-
Recursive Multi-Agent Processing: Implements adaptive multi-agent processing with dynamic task delegation, allowing the system to handle complex modules at scale while maintaining quality.
-
Multi-Modal Synthesis: Integrates textual descriptions with visual artifacts including architecture diagrams, data-flow representations, and sequence diagrams for comprehensive understanding.
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
β Codebase βββββΆβ Hierarchical βββββΆβ Multi-Agent β
β Analysis β β Decomposition β β Processing β
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
β β
βΌ βΌ
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
β Visual ββββββ Multi-Modal ββββββ Structured β
β Artifacts β β Synthesis β β Content β
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
- Python 3.12+
- Node.js (for Mermaid diagram validation)
- LLM API access (Anthropic Claude, OpenAI, etc.)
- Git (for branch creation features)