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)
pip install code2docsOr from source:
git clone https://github.com/wronai/code2docs
cd code2docs
pip install -e .pip install code2docs[watch] # file watcher (watchdog)
pip install code2docs[mkdocs] # MkDocs integration
pip install code2docs[dev] # development tools# 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-runfrom 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)<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
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__"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 code2docsgit clone https://github.com/wronai/code2docs
cd code2docs
pip install -e .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# 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-projectfrom 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)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
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__"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.
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
- π 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
| 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```
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.
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.
π¦ 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
- Python >= >=3.9
- code2llm >=0.5.0- jinja2 >=3.1- click >=8.0- pyyaml >=6.0- rich >=13.0
Contributors:
- Tom Softreck tom@sapletta.com
- Tom Sapletta tom-sapletta-com@users.noreply.github.com
We welcome contributions! Please see CONTRIBUTING.md for guidelines.
# Clone the repository
git clone https://github.com/wronai/code2docs
cd code2docs
# Install in development mode
pip install -e ".[dev]"
# Run tests
pytest- π 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
| 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
Apache License 2.0 - see [LICENSE](LICENSE) for details.
## Author
Created by **Tom Sapletta** - [tom@sapletta.com](mailto:tom@sapletta.com)