Auto-generate and sync project documentation from source code analysis
Project description
code2docs
AI Cost Tracking
- ๐ค LLM usage: $7.5000 (52 commits)
- ๐ค Human dev: ~$1621 (16.2h @ $100/h, 30min dedup)
Generated on 2026-03-31 using openrouter/qwen/qwen3-coder-next
Auto-generate and sync project documentation from source code analysis.
code2docs uses code2llm's AnalysisResult to produce human-readable documentation: README.md, API references, module docs, usage examples, and architecture diagrams.
code2llm โ AnalysisResult โ .toon / .mmd / context.md (for LLM)
code2docs โ AnalysisResult โ README.md / docs/ / examples/ (for humans)
Installation
pip install code2docs
Or from source:
git clone https://github.com/wronai/code2docs
cd code2docs
pip install -e .
Optional extras
pip install code2docs[watch] # file watcher (watchdog)
pip install code2docs[mkdocs] # MkDocs integration
pip install code2docs[dev] # development tools
Quick Start
# Generate full documentation for a project
code2docs ./my-project
# Generate only README
code2docs ./my-project --readme-only
# Sync (regenerate only changed modules)
code2docs sync ./my-project
# Watch mode (auto-resync on file changes)
code2docs watch ./my-project
# Initialize config file
code2docs init ./my-project
# Dry-run (show what would be generated)
code2docs ./my-project --dry-run
Python API
from code2docs import generate_readme, generate_docs, Code2DocsConfig
# Generate README
generate_readme("./my-project", output="README.md")
# Generate full docs with custom config
config = Code2DocsConfig(project_name="mylib", verbose=True)
docs = generate_docs("./my-project", config=config)
Generated Output
<project>/
โโโ README.md # Main README (auto-generated sections)
โโโ docs/
โ โโโ index.md # Documentation index
โ โโโ architecture.md # Architecture + Mermaid diagrams
โ โโโ api/
โ โ โโโ index.md # API overview
โ โ โโโ module_analyzer.md # Per-module API reference
โ โ โโโ ...
โ โโโ modules/
โ โโโ analyzer.md # Detailed module documentation
โ โโโ ...
โโโ examples/
โ โโโ basic_usage.py # Auto-generated usage example
โ โโโ class_examples.py # Class usage examples
โ โโโ ...
โโโ code2docs.yaml # Generator configuration
Configuration
Create code2docs.yaml in your project root (or run code2docs init):
project:
name: my-project
source: ./
output: ./docs/
readme:
sections:
- overview
- install
- quickstart
- api
- structure
- endpoints
badges:
- version
- python
- coverage
- complexity
sync_markers: true
docs:
api_reference: true
module_docs: true
architecture: true
changelog: true
examples:
auto_generate: true
from_entry_points: true
sync:
strategy: markers # markers | full | git-diff
watch: false
ignore:
- "tests/"
- "__pycache__"
Sync Markers
code2docs can update only specific sections of an existing README using markers:
<!-- code2docs:start --># code2docs
   
> **276** functions | **57** classes | **51** files | CCฬ = 3.8
> Auto-generated project documentation from source code analysis.
**Author:** Tom Sapletta
**License:** Apache-2.0[(LICENSE)](./LICENSE)
**Repository:** [https://github.com/wronai/code2docs](https://github.com/wronai/code2docs)
## Installation
### From PyPI
```bash
pip install code2docs
From Source
git clone https://github.com/wronai/code2docs
cd code2docs
pip install -e .
Optional Extras
pip install code2docs[llm] # LLM integration (litellm)
pip install code2docs[git] # Git integration (GitPython)
pip install code2docs[watch] # file watcher (watchdog)
pip install code2docs[mkdocs] # MkDocs integration
pip install code2docs[dev] # development tools
pip install code2docs[all] # all optional features
Quick Start
CLI Usage
# Generate full documentation for your project
code2docs ./my-project
# Only regenerate README
code2docs ./my-project --readme-only
# Preview what would be generated (no file writes)
code2docs ./my-project --dry-run
# Check documentation health
code2docs check ./my-project
# Sync โ regenerate only changed modules
code2docs sync ./my-project
Python API
from code2docs import generate_readme, generate_docs, Code2DocsConfig
# Quick: generate README
generate_readme("./my-project")
# Full: generate all documentation
config = Code2DocsConfig(project_name="mylib", verbose=True)
docs = generate_docs("./my-project", config=config)
Generated Output
When you run code2docs, the following files are produced:
<project>/
โโโ README.md # Main project README (auto-generated sections)
โโโ docs/
โ โโโ api.md # Consolidated API reference
โ โโโ modules.md # Module documentation with metrics
โ โโโ architecture.md # Architecture overview with diagrams
โ โโโ dependency-graph.md # Module dependency graphs
โ โโโ coverage.md # Docstring coverage report
โ โโโ getting-started.md # Getting started guide
โ โโโ configuration.md # Configuration reference
โ โโโ api-changelog.md # API change tracking
โโโ examples/
โ โโโ quickstart.py # Basic usage examples
โ โโโ advanced_usage.py # Advanced usage examples
โโโ CONTRIBUTING.md # Contribution guidelines
โโโ mkdocs.yml # MkDocs site configuration
Configuration
Create code2docs.yaml in your project root (or run code2docs init):
project:
name: my-project
source: ./
output: ./docs/
readme:
sections:
- overview
- install
- quickstart
- api
- structure
badges:
- version
- python
- coverage
sync_markers: true
docs:
api_reference: true
module_docs: true
architecture: true
changelog: true
examples:
auto_generate: true
from_entry_points: true
sync:
strategy: markers # markers | full | git-diff
watch: false
ignore:
- "tests/"
- "__pycache__"
Sync Markers
code2docs can update only specific sections of an existing README using HTML comment markers:
<!-- code2docs:start -->
# Project Title
... auto-generated content ...
<!-- code2docs:end -->
Content outside the markers is preserved when regenerating. Enable this with sync_markers: true in your configuration.
Architecture
code2docs/
โโโ registry โโโ llm_helperโโโ code2docs/ โโโ __main__ โโโ 04_sync_and_watch โโโ 05_custom_generators โโโ quickstart โโโ 06_formatters โโโ advanced_usage โโโ 03_programmatic_api โโโ entry_points โโโ 07_web_frameworks โโโ class_examples โโโ basic_usage โโโ 01_cli_usage โโโ 02_configuration โโโ updater โโโ sync/ โโโ watcher โโโ base โโโ quickstart โโโ advanced_usage โโโ markdown โโโ badges โโโ toc โโโ formatters/ โโโ differ โโโ coverage_gen โโโ _source_links โโโ depgraph_gen โโโ getting_started_gen โโโ config_docs_gen โโโ changelog_gen โโโ generators/ โโโ code2llm_gen โโโ module_docs_gen โโโ api_reference_gen โโโ examples_gen โโโ mkdocs_gen โโโ config โโโ api_changelog_gen โโโ _registry_adapters โโโ readme_gen โโโ contributing_gen โโโ analyzers/ โโโ dependency_scanner โโโ endpoint_detector โโโ architecture_gen โโโ project_scanner โโโ docstring_extractor โโโ cli```
## API Overview
### Classes
- **`GeneratorRegistry`** โ Registry of documentation generators.
- **`LLMHelper`** โ Thin wrapper around litellm for documentation generation.
- **`MetricsReportGenerator`** โ Generate a metrics report from code analysis.
- **`APIChangelogGenerator`** โ Generate changelog based on API changes.
- **`CustomGenerator`** โ Example of extending the base generator class.
- **`Updater`** โ Apply selective documentation updates based on detected changes.
- **`GenerateContext`** โ Shared context passed to all generators during a run.
- **`BaseGenerator`** โ Abstract base for all documentation generators.
- **`MarkdownFormatter`** โ Helper for constructing Markdown documents.
- **`ChangeInfo`** โ Describes a detected change.
- **`Differ`** โ Detect changes between current source and previous state.
- **`CoverageGenerator`** โ Generate docs/coverage.md โ docstring coverage report.
- **`SourceLinker`** โ Build source-code links (relative paths + optional GitHub/GitLab URLs).
- **`DepGraphGenerator`** โ Generate docs/dependency-graph.md with Mermaid diagrams.
- **`GettingStartedGenerator`** โ Generate docs/getting-started.md from entry points and dependencies.
- **`ConfigDocsGenerator`** โ Generate docs/configuration.md from Code2DocsConfig dataclass.
- **`ChangelogEntry`** โ A single changelog entry.
- **`ChangelogGenerator`** โ Generate CHANGELOG.md from git log and analysis diff.
- **`Code2LlmGenerator`** โ Generate code2llm analysis files in project/ directory.
- **`ModuleDocsGenerator`** โ Generate docs/modules.md โ consolidated module documentation.
- **`ApiReferenceGenerator`** โ Generate docs/api.md โ consolidated API reference.
- **`ExamplesGenerator`** โ Generate examples/ โ usage examples from public API signatures.
- **`MkDocsGenerator`** โ Generate mkdocs.yml from the docs/ directory structure.
- **`ReadmeConfig`** โ Configuration for README generation.
- **`DocsConfig`** โ Configuration for docs/ generation.
- **`ExamplesConfig`** โ Configuration for examples/ generation.
- **`SyncConfig`** โ Configuration for synchronization.
- **`Code2LlmConfig`** โ Configuration for code2llm analysis generation.
- **`LLMConfig`** โ Configuration for optional LLM-assisted documentation generation.
- **`Code2DocsConfig`** โ Main configuration for code2docs.
- **`ApiChange`** โ A single API change between two analysis snapshots.
- **`ApiChangelogGenerator`** โ Generate API changelog by diffing current analysis with a saved snapshot.
- **`ReadmeGeneratorAdapter`** โ โ
- **`ApiReferenceAdapter`** โ โ
- **`ModuleDocsAdapter`** โ โ
- **`ArchitectureAdapter`** โ โ
- **`DepGraphAdapter`** โ โ
- **`CoverageAdapter`** โ โ
- **`ApiChangelogAdapter`** โ โ
- **`ExamplesAdapter`** โ โ
- **`MkDocsAdapter`** โ โ
- **`GettingStartedAdapter`** โ โ
- **`ConfigDocsAdapter`** โ โ
- **`ContributingAdapter`** โ โ
- **`Code2LlmAdapter`** โ Adapter for code2llm analysis generation.
- **`ReadmeGenerator`** โ Generate README.md from AnalysisResult.
- **`ContributingGenerator`** โ Generate CONTRIBUTING.md by detecting dev tools from pyproject.toml.
- **`DependencyInfo`** โ Information about a project dependency.
- **`ProjectDependencies`** โ All detected project dependencies.
- **`DependencyScanner`** โ Scan and parse project dependency files.
- **`Endpoint`** โ Represents a detected web endpoint.
- **`EndpointDetector`** โ Detects web endpoints from decorator patterns in source code.
- **`ArchitectureGenerator`** โ Generate docs/architecture.md โ architecture overview with diagrams.
- **`ProjectScanner`** โ Wraps code2llm's ProjectAnalyzer with code2docs-specific defaults.
- **`DocstringInfo`** โ Parsed docstring with sections.
- **`DocstringExtractor`** โ Extract and parse docstrings from AnalysisResult.
- **`DefaultGroup`** โ Click Group that routes unknown subcommands to 'generate'.
### Functions
- `detect_changes_example(project_path)` โ Detect what files have changed since last documentation generation.
- `update_docs_incrementally(project_path)` โ Update only the parts of docs that need changing.
- `force_full_regeneration(project_path)` โ Force full regeneration of all documentation.
- `watch_and_auto_regenerate(project_path, interval)` โ Watch for file changes and auto-regenerate documentation.
- `custom_watcher_with_hooks(project_path)` โ Set up a custom watcher with pre/post generation hooks.
- `sync_with_git_changes(project_path)` โ Only regenerate docs for files changed in git.
- `generate_custom_report(project_path)` โ Generate a custom metrics report.
- `markdown_formatting_examples()` โ Demonstrate markdown formatting utilities.
- `generate_complex_document()` โ Generate a complex markdown document using the formatter.
- `badge_examples()` โ Generate various badge examples.
- `toc_examples()` โ Demonstrate table of contents generation.
- `build_custom_readme()` โ Build a custom README using formatters.
- `generate_readme_simple(project_path)` โ Generate README.md content from a project.
- `generate_full_documentation(project_path)` โ Generate complete documentation for a project.
- `custom_documentation_pipeline(project_path)` โ Create a custom documentation pipeline.
- `inspect_project_structure(project_path)` โ Inspect project structure from analysis.
- `generate_docs_if_needed(project_path, force)` โ Only generate docs if code has changed.
- `detect_flask_endpoints(project_path)` โ Detect Flask endpoints in a project.
- `detect_fastapi_endpoints(project_path)` โ Detect FastAPI endpoints in a project.
- `generate_api_docs_from_endpoints(project_path, output_dir)` โ Generate API documentation from detected endpoints.
- `create_example_web_apps(target_dir)` โ Create example Flask and FastAPI apps for testing.
- `document_web_project(project_path)` โ Complete workflow: detect endpoints and generate docs.
- `run_cli_basic(project_path)` โ Run code2docs CLI programmatically.
- `run_cli_with_config(project_path, config_path)` โ Run with custom configuration.
- `create_basic_config()` โ Create a basic configuration.
- `create_advanced_config()` โ Create advanced configuration with all options.
- `save_yaml_config_example(path)` โ Save example YAML config to file.
- `load_config_from_yaml(path)` โ Load configuration from YAML file.
- `start_watcher(project_path, config)` โ Start watching project for file changes and auto-resync docs.
- `generate_badges(project_name, badge_types, stats, deps)` โ Generate shields.io badge Markdown strings.
- `generate_toc(markdown_content, max_depth)` โ Generate a table of contents from Markdown headings.
- `extract_headings(content, max_depth)` โ Extract headings from Markdown content.
- `generate_docs(project_path, config)` โ High-level function to generate all documentation.
- `generate_code2llm_analysis(project_path, config)` โ Convenience function to generate code2llm analysis.
- `generate_readme(project_path, output, sections, sync_markers)` โ Convenience function to generate a README.
- `analyze_and_document(project_path, config)` โ Convenience function: analyze a project in one call.
- `main()` โ code2docs โ Auto-generate project documentation from source code.
- `generate(project_path, config_path, readme_only, sections)` โ Generate documentation (default command).
- `sync(project_path, config_path, verbose, dry_run)` โ Synchronize documentation with source code changes.
- `watch(project_path, config_path, verbose)` โ Watch for file changes and auto-regenerate docs.
- `init(project_path, output)` โ Initialize code2docs.yaml configuration file.
- `check(project_path, config_path, target)` โ Health check โ verify documentation completeness.
- `diff(project_path, config_path)` โ Preview what would change without writing anything.
## Project Structure
๐ฆ `code2docs` (1 functions)
๐ `code2docs.__main__`
๐ฆ `code2docs.analyzers`
๐ `code2docs.analyzers.dependency_scanner` (6 functions, 3 classes)
๐ `code2docs.analyzers.docstring_extractor` (10 functions, 2 classes)
๐ `code2docs.analyzers.endpoint_detector` (3 functions, 2 classes)
๐ `code2docs.analyzers.project_scanner` (4 functions, 1 classes)
๐ `code2docs.base` (3 functions, 2 classes)
๐ `code2docs.cli` (14 functions, 1 classes)
๐ `code2docs.config` (5 functions, 7 classes)
๐ `code2docs.examples.advanced_usage`
๐ `code2docs.examples.quickstart`
๐ฆ `code2docs.formatters`
๐ `code2docs.formatters.badges` (2 functions)
๐ `code2docs.formatters.markdown` (13 functions, 1 classes)
๐ `code2docs.formatters.toc` (3 functions)
๐ฆ `code2docs.generators` (1 functions)
๐ `code2docs.generators._registry_adapters` (26 functions, 13 classes)
๐ `code2docs.generators._source_links` (6 functions, 1 classes)
๐ `code2docs.generators.api_changelog_gen` (9 functions, 2 classes)
๐ `code2docs.generators.api_reference_gen` (7 functions, 1 classes)
๐ `code2docs.generators.architecture_gen` (10 functions, 1 classes)
๐ `code2docs.generators.changelog_gen` (6 functions, 2 classes)
๐ `code2docs.generators.code2llm_gen` (5 functions, 1 classes)
๐ `code2docs.generators.config_docs_gen` (4 functions, 1 classes)
๐ `code2docs.generators.contributing_gen` (8 functions, 1 classes)
๐ `code2docs.generators.coverage_gen` (7 functions, 1 classes)
๐ `code2docs.generators.depgraph_gen` (9 functions, 1 classes)
๐ `code2docs.generators.examples_gen` (14 functions, 1 classes)
๐ `code2docs.generators.getting_started_gen` (8 functions, 1 classes)
๐ `code2docs.generators.mkdocs_gen` (4 functions, 1 classes)
๐ `code2docs.generators.module_docs_gen` (9 functions, 1 classes)
๐ `code2docs.generators.readme_gen` (18 functions, 1 classes)
๐ `code2docs.llm_helper` (7 functions, 1 classes)
๐ `code2docs.registry` (4 functions, 1 classes)
๐ฆ `code2docs.sync`
๐ `code2docs.sync.differ` (7 functions, 2 classes)
๐ `code2docs.sync.updater` (2 functions, 1 classes)
๐ `code2docs.sync.watcher` (1 functions)
๐ `examples.01_cli_usage` (2 functions)
๐ `examples.02_configuration` (4 functions)
๐ `examples.03_programmatic_api` (5 functions)
๐ `examples.04_sync_and_watch` (6 functions)
๐ `examples.05_custom_generators` (13 functions, 3 classes)
๐ `examples.06_formatters` (5 functions)
๐ `examples.07_web_frameworks` (5 functions)
๐ `examples.advanced_usage`
๐ `examples.basic_usage`
๐ `examples.class_examples`
๐ `examples.entry_points`
๐ `examples.quickstart`
## Requirements
- Python >= >=3.9
- code2llm >=0.5.0- jinja2 >=3.1- click >=8.0- pyyaml >=6.0- rich >=13.0
## Contributing
**Contributors:**
- Tom Softreck <tom@sapletta.com>
- Tom Sapletta <tom-sapletta-com@users.noreply.github.com>
We welcome contributions! Please see [CONTRIBUTING.md](./CONTRIBUTING.md) for guidelines.
### Development Setup
```bash
# Clone the repository
git clone https://github.com/wronai/code2docs
cd code2docs
# Install in development mode
pip install -e ".[dev]"
# Run tests
pytest
Documentation
- ๐ Full Documentation โ API reference, module docs, architecture
- ๐ Getting Started โ Quick start guide
- ๐ API Reference โ Complete API documentation
- ๐ง Configuration โ Configuration options
- ๐ก Examples โ Usage examples and code samples
Generated Files
| Output | Description | Link |
|---|---|---|
README.md |
Project overview (this file) | โ |
docs/api.md |
Consolidated API reference | View |
docs/modules.md |
Module reference with metrics | View |
docs/architecture.md |
Architecture with diagrams | View |
docs/dependency-graph.md |
Dependency graphs | View |
docs/coverage.md |
Docstring coverage report | View |
docs/getting-started.md |
Getting started guide | View |
docs/configuration.md |
Configuration reference | View |
docs/api-changelog.md |
API change tracking | View |
CONTRIBUTING.md |
Contribution guidelines | View |
examples/ |
Usage examples | Browse |
mkdocs.yml |
MkDocs configuration | โ |
Content outside the markers is preserved when regenerating. Enable this with `sync_markers: true` in your configuration.
## Architecture
code2docs/ โโโ registry โโโ llm_helperโโโ code2docs/ โโโ main โโโ 04_sync_and_watch โโโ 05_custom_generators โโโ 06_formatters โโโ 03_programmatic_api โโโ entry_points โโโ 07_web_frameworks โโโ class_examples โโโ basic_usage โโโ 01_cli_usage โโโ 02_configuration โโโ updater โโโ sync/ โโโ watcher โโโ differ โโโ quickstart โโโ base โโโ advanced_usage โโโ badges โโโ markdown โโโ formatters/ โโโ toc โโโ coverage_gen โโโ _source_links โโโ depgraph_gen โโโ getting_started_gen โโโ config_docs_gen โโโ changelog_gen โโโ generators/ โโโ code2llm_gen โโโ module_docs_gen โโโ api_reference_gen โโโ examples_gen โโโ mkdocs_gen โโโ config โโโ api_changelog_gen โโโ _registry_adapters โโโ contributing_gen โโโ readme_gen โโโ analyzers/ โโโ docstring_extractor โโโ endpoint_detector โโโ architecture_gen โโโ project_scanner โโโ cli โโโ dependency_scanner```
API Overview
Classes
GeneratorRegistryโ Registry of documentation generators.LLMHelperโ Thin wrapper around litellm for documentation generation.MetricsReportGeneratorโ Generate a metrics report from code analysis.APIChangelogGeneratorโ Generate changelog based on API changes.CustomGeneratorโ Example of extending the base generator class.Updaterโ Apply selective documentation updates based on detected changes.ChangeInfoโ Describes a detected change.Differโ Detect changes between current source and previous state.GenerateContextโ Shared context passed to all generators during a run.BaseGeneratorโ Abstract base for all documentation generators.MarkdownFormatterโ Helper for constructing Markdown documents.CoverageGeneratorโ Generate docs/coverage.md โ docstring coverage report.SourceLinkerโ Build source-code links (relative paths + optional GitHub/GitLab URLs).DepGraphGeneratorโ Generate docs/dependency-graph.md with Mermaid diagrams.GettingStartedGeneratorโ Generate docs/getting-started.md from entry points and dependencies.ConfigDocsGeneratorโ Generate docs/configuration.md from Code2DocsConfig dataclass.ChangelogEntryโ A single changelog entry.ChangelogGeneratorโ Generate CHANGELOG.md from git log and analysis diff.Code2LlmGeneratorโ Generate code2llm analysis files in project/ directory.ModuleDocsGeneratorโ Generate docs/modules.md โ consolidated module documentation.ApiReferenceGeneratorโ Generate docs/api.md โ consolidated API reference.ExamplesGeneratorโ Generate examples/ โ usage examples from public API signatures.MkDocsGeneratorโ Generate mkdocs.yml from the docs/ directory structure.ReadmeConfigโ Configuration for README generation.DocsConfigโ Configuration for docs/ generation.ExamplesConfigโ Configuration for examples/ generation.SyncConfigโ Configuration for synchronization.Code2LlmConfigโ Configuration for code2llm analysis generation.LLMConfigโ Configuration for optional LLM-assisted documentation generation.Code2DocsConfigโ Main configuration for code2docs.ApiChangeโ A single API change between two analysis snapshots.ApiChangelogGeneratorโ Generate API changelog by diffing current analysis with a saved snapshot.ReadmeGeneratorAdapterโ โApiReferenceAdapterโ โModuleDocsAdapterโ โArchitectureAdapterโ โDepGraphAdapterโ โCoverageAdapterโ โApiChangelogAdapterโ โExamplesAdapterโ โMkDocsAdapterโ โGettingStartedAdapterโ โConfigDocsAdapterโ โContributingAdapterโ โCode2LlmAdapterโ Adapter for code2llm analysis generation.ContributingGeneratorโ Generate CONTRIBUTING.md by detecting dev tools from pyproject.toml.ReadmeGeneratorโ Generate README.md from AnalysisResult.DocstringInfoโ Parsed docstring with sections.DocstringExtractorโ Extract and parse docstrings from AnalysisResult.Endpointโ Represents a detected web endpoint.EndpointDetectorโ Detects web endpoints from decorator patterns in source code.ArchitectureGeneratorโ Generate docs/architecture.md โ architecture overview with diagrams.ProjectScannerโ Wraps code2llm's ProjectAnalyzer with code2docs-specific defaults.DefaultGroupโ Click Group that routes unknown subcommands to 'generate'.DependencyInfoโ Information about a project dependency.ProjectDependenciesโ All detected project dependencies.DependencyScannerโ Scan and parse project dependency files.
Functions
detect_changes_example(project_path)โ Detect what files have changed since last documentation generation.update_docs_incrementally(project_path)โ Update only the parts of docs that need changing.force_full_regeneration(project_path)โ Force full regeneration of all documentation.watch_and_auto_regenerate(project_path, interval)โ Watch for file changes and auto-regenerate documentation.custom_watcher_with_hooks(project_path)โ Set up a custom watcher with pre/post generation hooks.sync_with_git_changes(project_path)โ Only regenerate docs for files changed in git.generate_custom_report(project_path)โ Generate a custom metrics report.markdown_formatting_examples()โ Demonstrate markdown formatting utilities.generate_complex_document()โ Generate a complex markdown document using the formatter.badge_examples()โ Generate various badge examples.toc_examples()โ Demonstrate table of contents generation.build_custom_readme()โ Build a custom README using formatters.generate_readme_simple(project_path)โ Generate README.md content from a project.generate_full_documentation(project_path)โ Generate complete documentation for a project.custom_documentation_pipeline(project_path)โ Create a custom documentation pipeline.inspect_project_structure(project_path)โ Inspect project structure from analysis.generate_docs_if_needed(project_path, force)โ Only generate docs if code has changed.detect_flask_endpoints(project_path)โ Detect Flask endpoints in a project.detect_fastapi_endpoints(project_path)โ Detect FastAPI endpoints in a project.generate_api_docs_from_endpoints(project_path, output_dir)โ Generate API documentation from detected endpoints.create_example_web_apps(target_dir)โ Create example Flask and FastAPI apps for testing.document_web_project(project_path)โ Complete workflow: detect endpoints and generate docs.run_cli_basic(project_path)โ Run code2docs CLI programmatically.run_cli_with_config(project_path, config_path)โ Run with custom configuration.create_basic_config()โ Create a basic configuration.create_advanced_config()โ Create advanced configuration with all options.save_yaml_config_example(path)โ Save example YAML config to file.load_config_from_yaml(path)โ Load configuration from YAML file.start_watcher(project_path, config)โ Start watching project for file changes and auto-resync docs.generate_badges(project_name, badge_types, stats, deps)โ Generate shields.io badge Markdown strings.generate_toc(markdown_content, max_depth)โ Generate a table of contents from Markdown headings.extract_headings(content, max_depth)โ Extract headings from Markdown content.generate_docs(project_path, config)โ High-level function to generate all documentation.generate_code2llm_analysis(project_path, config)โ Convenience function to generate code2llm analysis.generate_readme(project_path, output, sections, sync_markers)โ Convenience function to generate a README.analyze_and_document(project_path, config)โ Convenience function: analyze a project in one call.main()โ code2docs โ Auto-generate project documentation from source code.generate(project_path, config_path, readme_only, sections)โ Generate documentation (default command).sync(project_path, config_path, verbose, dry_run)โ Synchronize documentation with source code changes.watch(project_path, config_path, verbose)โ Watch for file changes and auto-regenerate docs.init(project_path, output)โ Initialize code2docs.yaml configuration file.check(project_path, config_path, target)โ Health check โ verify documentation completeness.diff(project_path, config_path)โ Preview what would change without writing anything.
Project Structure
๐ฆ code2docs (1 functions)
๐ code2docs.__main__
๐ฆ code2docs.analyzers
๐ code2docs.analyzers.dependency_scanner (6 functions, 3 classes)
๐ code2docs.analyzers.docstring_extractor (10 functions, 2 classes)
๐ code2docs.analyzers.endpoint_detector (3 functions, 2 classes)
๐ code2docs.analyzers.project_scanner (4 functions, 1 classes)
๐ code2docs.base (3 functions, 2 classes)
๐ code2docs.cli (14 functions, 1 classes)
๐ code2docs.config (5 functions, 7 classes)
๐ code2docs.examples.advanced_usage
๐ code2docs.examples.quickstart
๐ฆ code2docs.formatters
๐ code2docs.formatters.badges (2 functions)
๐ code2docs.formatters.markdown (13 functions, 1 classes)
๐ code2docs.formatters.toc (3 functions)
๐ฆ code2docs.generators (1 functions)
๐ code2docs.generators._registry_adapters (26 functions, 13 classes)
๐ code2docs.generators._source_links (6 functions, 1 classes)
๐ code2docs.generators.api_changelog_gen (9 functions, 2 classes)
๐ code2docs.generators.api_reference_gen (7 functions, 1 classes)
๐ code2docs.generators.architecture_gen (10 functions, 1 classes)
๐ code2docs.generators.changelog_gen (6 functions, 2 classes)
๐ code2docs.generators.code2llm_gen (5 functions, 1 classes)
๐ code2docs.generators.config_docs_gen (4 functions, 1 classes)
๐ code2docs.generators.contributing_gen (8 functions, 1 classes)
๐ code2docs.generators.coverage_gen (7 functions, 1 classes)
๐ code2docs.generators.depgraph_gen (9 functions, 1 classes)
๐ code2docs.generators.examples_gen (14 functions, 1 classes)
๐ code2docs.generators.getting_started_gen (8 functions, 1 classes)
๐ code2docs.generators.mkdocs_gen (4 functions, 1 classes)
๐ code2docs.generators.module_docs_gen (9 functions, 1 classes)
๐ code2docs.generators.readme_gen (18 functions, 1 classes)
๐ code2docs.llm_helper (7 functions, 1 classes)
๐ code2docs.registry (4 functions, 1 classes)
๐ฆ code2docs.sync
๐ code2docs.sync.differ (7 functions, 2 classes)
๐ code2docs.sync.updater (2 functions, 1 classes)
๐ code2docs.sync.watcher (1 functions)
๐ examples.01_cli_usage (2 functions)
๐ examples.02_configuration (4 functions)
๐ examples.03_programmatic_api (5 functions)
๐ examples.04_sync_and_watch (6 functions)
๐ examples.05_custom_generators (13 functions, 3 classes)
๐ examples.06_formatters (5 functions)
๐ examples.07_web_frameworks (5 functions)
๐ examples.basic_usage
๐ examples.class_examples
๐ examples.entry_points
Requirements
- Python >= >=3.9
- code2llm >=0.5.0- jinja2 >=3.1- click >=8.0- pyyaml >=6.0- rich >=13.0
Contributing
Contributors:
- Tom Softreck tom@sapletta.com
- Tom Sapletta tom-sapletta-com@users.noreply.github.com
We welcome contributions! Please see CONTRIBUTING.md for guidelines.
Development Setup
# Clone the repository
git clone https://github.com/wronai/code2docs
cd code2docs
# Install in development mode
pip install -e ".[dev]"
# Run tests
pytest
Documentation
- ๐ Full Documentation โ API reference, module docs, architecture
- ๐ Getting Started โ Quick start guide
- ๐ API Reference โ Complete API documentation
- ๐ง Configuration โ Configuration options
- ๐ก Examples โ Usage examples and code samples
Generated Files
| Output | Description | Link |
|---|---|---|
README.md |
Project overview (this file) | โ |
docs/api.md |
Consolidated API reference | View |
docs/modules.md |
Module reference with metrics | View |
docs/architecture.md |
Architecture with diagrams | View |
docs/dependency-graph.md |
Dependency graphs | View |
docs/coverage.md |
Docstring coverage report | View |
docs/getting-started.md |
Getting started guide | View |
docs/configuration.md |
Configuration reference | View |
docs/api-changelog.md |
API change tracking | View |
CONTRIBUTING.md |
Contribution guidelines | View |
examples/ |
Usage examples | Browse |
mkdocs.yml |
MkDocs configuration | โ |
Content outside markers is preserved.
## Architecture
code2docs/ โโโ cli.py # CLI (click-based) โโโ config.py # Configuration (code2docs.yaml) โโโ analyzers/ # Adapters to code2llm + custom detectors โ โโโ project_scanner.py # Wrapper on code2llm.ProjectAnalyzer โ โโโ endpoint_detector.py # Flask/FastAPI/Django route extraction โ โโโ docstring_extractor.py โ โโโ dependency_scanner.py โโโ generators/ # Documentation generators โ โโโ readme_gen.py # README.md generator โ โโโ api_reference_gen.py # docs/api/ reference from signatures โ โโโ module_docs_gen.py # docs/modules/ per-module docs โ โโโ examples_gen.py # examples/ from signatures โ โโโ changelog_gen.py # CHANGELOG from git log โ โโโ architecture_gen.py # Architecture + Mermaid diagrams โโโ templates/ # Jinja2 templates โโโ sync/ # Change detection & selective regeneration โ โโโ differ.py โ โโโ updater.py โ โโโ watcher.py โโโ formatters/ # Markdown, badges, TOC
## Requirements
- Python >= 3.9
- [code2llm](https://github.com/wronai/code2llm) >= 0.5.0
- Jinja2 >= 3.1
- Click >= 8.0
- PyYAML >= 6.0
## License
Licensed under Apache-2.0.
## Author
Tom Sapletta
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file code2docs-3.0.25.tar.gz.
File metadata
- Download URL: code2docs-3.0.25.tar.gz
- Upload date:
- Size: 88.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a2ea5730456f031704af5cd9fa5a94ed05d1c1388e5fe466aecda30aea09c68f
|
|
| MD5 |
7e1416b02364c5b1446286d8d3706fa6
|
|
| BLAKE2b-256 |
9cf8a966431d339a85ecef80dfe39e7ca8a56cff14d7c9e92241fa06b9094f2d
|
File details
Details for the file code2docs-3.0.25-py3-none-any.whl.
File metadata
- Download URL: code2docs-3.0.25-py3-none-any.whl
- Upload date:
- Size: 88.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cff1b1a9d47526de64e1a8d642ff6c7f480e02f734f951417e30e1d5fcf7fbd5
|
|
| MD5 |
b94e6b8ebe63a867503ebca2232b1006
|
|
| BLAKE2b-256 |
1150addefb4a8ea4244de67000194828ce41c87d9e9c9a9c3d6a21356fd9c035
|