Skip to content

Commit fe6bec4

Browse files
docs(docs): add markdown output
Statistics: 5 files changed, 82 insertions, 109 deletions Summary: - Dirs: .=1, code2docs=1, docs=1, examples=1, project=1 - Exts: .md=2, .py=2, .yaml=1 - A/M/D: 0/5/0 Modified files: - README.md (+2/-2) - code2docs/generators/examples_gen.py (+6/-34) - docs/README.md (+56/-54) - examples/class_examples.py (+15/-16) - project/duplication.toon.yaml (+3/-3) Changes (notes): - README.md (+2/-2): update documentation - code2docs/generators/examples_gen.py (+6/-34): update - docs/README.md (+56/-54): update documentation - examples/class_examples.py (+15/-16): add markdown formatting - project/duplication.toon.yaml (+3/-3): update Implementation notes (heuristics): - Type inferred from file paths + diff keywords + add/delete ratio - Scope prefers 'goal' when goal/* is touched; otherwise based on top-level dirs - For <=6 files: generate short per-file notes from added lines (defs/classes/click options/headings) - A/M/D derived from git name-status; per-file +X/-X from git numstat
1 parent ae5a340 commit fe6bec4

9 files changed

Lines changed: 98 additions & 114 deletions

File tree

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@
22

33
## [Unreleased]
44

5+
## [3.0.32] - 2026-04-20
6+
7+
### Docs
8+
- Update README.md
9+
- Update docs/README.md
10+
11+
### Other
12+
- Update code2docs/generators/examples_gen.py
13+
- Update examples/class_examples.py
14+
- Update project/duplication.toon.yaml
15+
516
## [3.0.31] - 2026-04-20
617

718
### Docs

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
## AI Cost Tracking
22

3-
![PyPI](https://img.shields.io/badge/pypi-costs-blue) ![Version](https://img.shields.io/badge/version-3.0.31-blue) ![Python](https://img.shields.io/badge/python-3.9+-blue) ![License](https://img.shields.io/badge/license-Apache--2.0-green)
3+
![PyPI](https://img.shields.io/badge/pypi-costs-blue) ![Version](https://img.shields.io/badge/version-3.0.32-blue) ![Python](https://img.shields.io/badge/python-3.9+-blue) ![License](https://img.shields.io/badge/license-Apache--2.0-green)
44
![AI Cost](https://img.shields.io/badge/AI%20Cost-$7.50-orange) ![Human Time](https://img.shields.io/badge/Human%20Time-25.3h-blue) ![Model](https://img.shields.io/badge/Model-openrouter%2Fqwen%2Fqwen3--coder--next-lightgrey)
55

6-
- 🤖 **LLM usage:** $7.5000 (71 commits)
6+
- 🤖 **LLM usage:** $7.5000 (72 commits)
77
- 👤 **Human dev:** ~$2534 (25.3h @ $100/h, 30min dedup)
88

99
Generated on 2026-04-20 using [openrouter/qwen/qwen3-coder-next](https://openrouter.ai/qwen/qwen3-coder-next)
1010

1111
---
1212

13-
![version](https://img.shields.io/badge/version-3.0.31-blue) ![python](https://img.shields.io/badge/python-%3E%3D3.9-blue) ![docs](https://img.shields.io/badge/docs-auto--generated-blueviolet)
13+
![version](https://img.shields.io/badge/version-3.0.32-blue) ![python](https://img.shields.io/badge/python-%3E%3D3.9-blue) ![docs](https://img.shields.io/badge/docs-auto--generated-blueviolet)
1414

1515
> Auto-generate and sync project documentation from source code analysis.
1616
@@ -147,7 +147,7 @@ code2docs can update only specific sections of an existing README using markers:
147147
```markdown
148148
<!-- code2docs:start --># code2docs
149149

150-
![version](https://img.shields.io/badge/version-3.0.31-blue) ![python](https://img.shields.io/badge/python-%3E%3D3.9-blue) ![coverage](https://img.shields.io/badge/coverage-unknown-lightgrey) ![functions](https://img.shields.io/badge/functions-276-green)
150+
![version](https://img.shields.io/badge/version-3.0.32-blue) ![python](https://img.shields.io/badge/python-%3E%3D3.9-blue) ![coverage](https://img.shields.io/badge/coverage-unknown-lightgrey) ![functions](https://img.shields.io/badge/functions-276-green)
151151
> **276** functions | **57** classes | **51** files | CC̄ = 3.8
152152

153153
> Auto-generated project documentation from source code analysis.

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.0.31
1+
3.0.32

code2docs/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
README.md, API references, module docs, examples, and architecture diagrams.
66
"""
77

8-
__version__ = '3.0.31'
8+
__version__ = '3.0.32'
99
__author__ = 'Tom Sapletta'
1010
__all__ = ['Code2DocsConfig', 'generate_readme', 'generate_docs', 'analyze_and_document']
1111

code2docs/generators/examples_gen.py

Lines changed: 6 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,3 @@
1-
2-
PORT_4 = 4
3-
CONSTANT_5 = 5
4-
CONSTANT_50 = 50
5-
6-
7-
PORT_4 = PORT_4
8-
CONSTANT_5 = CONSTANT_5
9-
CONSTANT_50 = CONSTANT_50
10-
11-
12-
PORT_4 = PORT_4
13-
CONSTANT_5 = CONSTANT_5
14-
CONSTANT_50 = CONSTANT_50
15-
16-
17-
PORT_4 = PORT_4
18-
CONSTANT_5 = CONSTANT_5
19-
CONSTANT_50 = CONSTANT_50
20-
21-
22-
23-
PORT_4 = PORT_4
24-
CONSTANT_5 = CONSTANT_5
25-
CONSTANT_50 = CONSTANT_50
26-
27-
PORT_4 = PORT_4
28-
CONSTANT_5 = CONSTANT_5
29-
CONSTANT_50 = CONSTANT_50
30-
311
"""Auto-generate usage examples from public signatures and entry points."""
322

333
from pathlib import Path
@@ -37,10 +7,12 @@
377

388
from ..config import Code2DocsConfig
399

40-
# Default type hints → example values
10+
PORT_4 = 4
11+
CONSTANT_5 = 5
12+
CONSTANT_50 = 50
4113

42-
if __name__ == "__main__":
43-
_TYPE_EXAMPLES = {
14+
# Default type hints → example values
15+
_TYPE_EXAMPLES = {
4416
"str": '"./my-project"',
4517
"Path": 'Path("./my-project")',
4618
"int": "10",
@@ -55,7 +27,7 @@
5527
}
5628

5729
# Arg name → realistic example value
58-
_ARG_EXAMPLES = {
30+
_ARG_EXAMPLES = {
5931
"project_path": '"./my-project"',
6032
"path": '"./my-project"',
6133
"source": '"./src"',

docs/README.md

Lines changed: 56 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -126,85 +126,84 @@ docs = generate_docs("./my-project", config=config)
126126
```
127127
code2docs/
128128
├── project
129-
├── updater
129+
├── advanced_usage
130130
├── badges
131131
├── toc
132132
├── formatters/
133-
├── quickstart
134-
├── advanced_usage
135-
├── sync/
133+
├── registry
136134
├── coverage_gen
137135
├── _source_links
138-
├── watcher
136+
├── readme_gen
139137
├── __main__
138+
├── watcher
140139
├── depgraph_gen
141-
├── config_docs_gen
142-
├── getting_started_gen
143-
├── readme_gen
144140
├── generators/
145-
├── advanced_usage
146-
├── quickstart
147-
├── code2llm_gen
148-
├── mkdocs_gen
149-
├── differ
150-
├── api_reference_gen
141+
├── getting_started_gen
142+
├── config_docs_gen
143+
├── module_docs_gen
151144
├── org_readme_gen
145+
├── code2llm_gen
152146
├── code2docs/
153-
├── analyzers/
154-
├── module_docs_gen
147+
├── api_reference_gen
148+
├── changelog_gen
149+
├── mkdocs_gen
150+
├── advanced_usage
155151
├── contributing_gen
152+
├── updater
153+
├── analyzers/
156154
├── architecture_gen
157-
├── changelog_gen
158-
├── registry
159-
├── quickstart
160155
├── _registry_adapters
156+
├── api_changelog_gen
161157
├── 04_sync_and_watch
162-
├── advanced_usage
158+
├── quickstart
159+
├── quickstart
163160
├── 05_custom_generators
164-
├── entry_points
161+
├── advanced_usage
165162
├── 06_formatters
166-
├── examples_gen
163+
├── 03_programmatic_api
164+
├── entry_points
165+
├── class_examples
167166
├── basic_usage
167+
├── 07_web_frameworks
168168
├── 01_cli_usage
169-
├── 03_programmatic_api
170169
├── 02_configuration
171-
├── 07_web_frameworks
172-
├── api_changelog_gen
170+
├── examples_gen
171+
├── differ
173172
├── markdown
173+
├── sync/
174+
├── quickstart
174175
├── base
175-
├── cli
176-
├── docstring_extractor
177176
├── markdown_validator
177+
├── cli
178178
├── endpoint_detector
179-
├── dependency_scanner
180179
├── project_scanner
180+
├── dependency_scanner
181181
├── config
182+
├── docstring_extractor
182183
├── llm_helper
183184
```
184185
185186
## API Overview
186187
187188
### Classes
188189
189-
- **`Updater`** — Apply selective documentation updates based on detected changes.
190+
- **`GeneratorRegistry`** — Registry of documentation generators.
190191
- **`CoverageGenerator`** — Generate docs/coverage.md — docstring coverage report.
191192
- **`SourceLinker`** — Build source-code links (relative paths + optional GitHub/GitLab URLs).
193+
- **`ReadmeGenerator`** — Generate README.md from AnalysisResult.
192194
- **`DepGraphGenerator`** — Generate docs/dependency-graph.md with Mermaid diagrams.
193-
- **`ConfigDocsGenerator`** — Generate docs/configuration.md from Code2DocsConfig dataclass.
194195
- **`GettingStartedGenerator`** — Generate docs/getting-started.md from entry points and dependencies.
195-
- **`ReadmeGenerator`** — Generate README.md from AnalysisResult.
196+
- **`ConfigDocsGenerator`** — Generate docs/configuration.md from Code2DocsConfig dataclass.
197+
- **`ModuleDocsGenerator`** — Generate docs/modules.md — consolidated module documentation.
198+
- **`OrgReadmeGenerator`** — Generate organization README with list of projects and brief descriptions.
196199
- **`Code2LlmGenerator`** — Generate code2llm analysis files in project/ directory.
197-
- **`MkDocsGenerator`** — Generate mkdocs.yml from the docs/ directory structure.
198-
- **`ChangeInfo`** — Describes a detected change.
199-
- **`Differ`** — Detect changes between current source and previous state.
200200
- **`ApiReferenceGenerator`** — Generate docs/api.md — consolidated API reference.
201-
- **`OrgReadmeGenerator`** — Generate organization README with list of projects and brief descriptions.
202-
- **`ModuleDocsGenerator`** — Generate docs/modules.md — consolidated module documentation.
203-
- **`ContributingGenerator`** — Generate CONTRIBUTING.md by detecting dev tools from pyproject.toml.
204-
- **`ArchitectureGenerator`** — Generate docs/architecture.md — architecture overview with diagrams.
205201
- **`ChangelogEntry`** — A single changelog entry.
206202
- **`ChangelogGenerator`** — Generate CHANGELOG.md from git log and analysis diff.
207-
- **`GeneratorRegistry`** — Registry of documentation generators.
203+
- **`MkDocsGenerator`** — Generate mkdocs.yml from the docs/ directory structure.
204+
- **`ContributingGenerator`** — Generate CONTRIBUTING.md by detecting dev tools from pyproject.toml.
205+
- **`Updater`** — Apply selective documentation updates based on detected changes.
206+
- **`ArchitectureGenerator`** — Generate docs/architecture.md — architecture overview with diagrams.
208207
- **`ReadmeGeneratorAdapter`** — —
209208
- **`ApiReferenceAdapter`** — —
210209
- **`ModuleDocsAdapter`** — —
@@ -220,42 +219,44 @@ code2docs/
220219
- **`Code2LlmAdapter`** — Adapter for code2llm analysis generation.
221220
- **`OrgReadmeAdapter`** — Adapter for organization README generation.
222221
- **`IndexHtmlAdapter`** — Adapter for generating index.html for GitHub Pages browsing.
222+
- **`ApiChange`** — A single API change between two analysis snapshots.
223+
- **`ApiChangelogGenerator`** — Generate API changelog by diffing current analysis with a saved snapshot.
223224
- **`MetricsReportGenerator`** — Generate a metrics report from code analysis.
224225
- **`APIChangelogGenerator`** — Generate changelog based on API changes.
225226
- **`CustomGenerator`** — Example of extending the base generator class.
226227
- **`ExamplesGenerator`** — Generate examples/ — usage examples from public API signatures.
227-
- **`ApiChange`** — A single API change between two analysis snapshots.
228-
- **`ApiChangelogGenerator`** — Generate API changelog by diffing current analysis with a saved snapshot.
228+
- **`ChangeInfo`** — Describes a detected change.
229+
- **`Differ`** — Detect changes between current source and previous state.
229230
- **`MarkdownFormatter`** — Helper for constructing Markdown documents.
230231
- **`GenerateContext`** — Shared context passed to all generators during a run.
231232
- **`BaseGenerator`** — Abstract base for all documentation generators.
232-
- **`DefaultGroup`** — Click Group that routes unknown subcommands to 'generate'.
233-
- **`DocstringInfo`** — Parsed docstring with sections.
234-
- **`DocstringExtractor`** — Extract and parse docstrings from AnalysisResult.
235233
- **`MarkdownIssue`** — A single validation issue in a markdown file.
236234
- **`ValidationReport`** — Aggregate result of markdown validation.
235+
- **`DefaultGroup`** — Click Group that routes unknown subcommands to 'generate'.
237236
- **`Endpoint`** — Represents a detected web endpoint.
238237
- **`EndpointDetector`** — Detects web endpoints from decorator patterns in source code.
238+
- **`ProjectScanner`** — Wraps code2llm's ProjectAnalyzer with code2docs-specific defaults.
239239
- **`DependencyInfo`** — Information about a project dependency.
240240
- **`ProjectDependencies`** — All detected project dependencies.
241241
- **`DependencyScanner`** — Scan and parse project dependency files.
242-
- **`ProjectScanner`** — Wraps code2llm's ProjectAnalyzer with code2docs-specific defaults.
243242
- **`ReadmeConfig`** — Configuration for README generation.
244243
- **`DocsConfig`** — Configuration for docs/ generation.
245244
- **`ExamplesConfig`** — Configuration for examples/ generation.
246245
- **`SyncConfig`** — Configuration for synchronization.
247246
- **`Code2LlmConfig`** — Configuration for code2llm analysis generation.
248247
- **`LLMConfig`** — Configuration for optional LLM-assisted documentation generation.
249248
- **`Code2DocsConfig`** — Main configuration for code2docs.
249+
- **`DocstringInfo`** — Parsed docstring with sections.
250+
- **`DocstringExtractor`** — Extract and parse docstrings from AnalysisResult.
250251
- **`LLMHelper`** — Thin wrapper around litellm for documentation generation.
251252
252253
### Functions
253254
254255
- `generate_badges(project_name, badge_types, stats, deps)` — Generate shields.io badge Markdown strings.
255256
- `generate_toc(markdown_content, max_depth)` — Generate a table of contents from Markdown headings.
256257
- `extract_headings(content, max_depth)` — Extract headings from Markdown content.
257-
- `start_watcher(project_path, config)` — Start watching project for file changes and auto-resync docs.
258258
- `generate_readme(project_path, output, sections, sync_markers)` — Convenience function to generate a README.
259+
- `start_watcher(project_path, config)` — Start watching project for file changes and auto-resync docs.
259260
- `generate_docs(project_path, config)` — High-level function to generate all documentation.
260261
- `parse_gitignore(project_path)` — Parse .gitignore file and return list of patterns to exclude.
261262
- `generate_code2llm_analysis(project_path, config)` — Convenience function to generate code2llm analysis.
@@ -271,22 +272,24 @@ code2docs/
271272
- `badge_examples()` — Generate various badge examples.
272273
- `toc_examples()` — Demonstrate table of contents generation.
273274
- `build_custom_readme()` — Build a custom README using formatters.
274-
- `run_cli_basic(project_path)` — Run code2docs CLI programmatically.
275-
- `run_cli_with_config(project_path, config_path)` — Run with custom configuration.
276275
- `generate_readme_simple(project_path)` — Generate README.md content from a project.
277276
- `generate_full_documentation(project_path)` — Generate complete documentation for a project.
278277
- `custom_documentation_pipeline(project_path)` — Create a custom documentation pipeline.
279278
- `inspect_project_structure(project_path)` — Inspect project structure from analysis.
280279
- `generate_docs_if_needed(project_path, force)` — Only generate docs if code has changed.
281-
- `create_basic_config()` — Create a basic configuration.
282-
- `create_advanced_config()` — Create advanced configuration with all options.
283-
- `save_yaml_config_example(path)` — Save example YAML config to file.
284-
- `load_config_from_yaml(path)` — Load configuration from YAML file.
285280
- `detect_flask_endpoints(project_path)` — Detect Flask endpoints in a project.
286281
- `detect_fastapi_endpoints(project_path)` — Detect FastAPI endpoints in a project.
287282
- `generate_api_docs_from_endpoints(project_path, output_dir)` — Generate API documentation from detected endpoints.
288283
- `create_example_web_apps(target_dir)` — Create example Flask and FastAPI apps for testing.
289284
- `document_web_project(project_path)` — Complete workflow: detect endpoints and generate docs.
285+
- `run_cli_basic(project_path)` — Run code2docs CLI programmatically.
286+
- `run_cli_with_config(project_path, config_path)` — Run with custom configuration.
287+
- `create_basic_config()` — Create a basic configuration.
288+
- `create_advanced_config()` — Create advanced configuration with all options.
289+
- `save_yaml_config_example(path)` — Save example YAML config to file.
290+
- `load_config_from_yaml(path)` — Load configuration from YAML file.
291+
- `validate_markdown_file(md_path, project_root)` — Validate a single markdown file.
292+
- `validate_markdown_tree(root, patterns, ignore)` — Validate every markdown file under ``root`` matching ``patterns``.
290293
- `main()` — code2docs — Auto-generate project documentation from source code.
291294
- `generate(project_path, config_path, readme_only, sections)` — Generate documentation (default command).
292295
- `sync(project_path, config_path, verbose, dry_run)` — Synchronize documentation with source code changes.
@@ -295,8 +298,6 @@ code2docs/
295298
- `check(project_path, config_path, target)` — Health check — verify documentation completeness.
296299
- `validate(project_path, pattern, strict)` — Validate generated markdown: broken links, table shape, duplicate headings.
297300
- `diff(project_path, config_path)` — Preview what would change without writing anything.
298-
- `validate_markdown_file(md_path, project_root)` — Validate a single markdown file.
299-
- `validate_markdown_tree(root, patterns, ignore)` — Validate every markdown file under ``root`` matching ``patterns``.
300301
- `analyze_and_document(project_path, config)` — Convenience function: analyze a project in one call.
301302
302303
@@ -354,6 +355,7 @@ code2docs/
354355
📄 `examples.07_web_frameworks` (5 functions)
355356
📄 `examples.advanced_usage`
356357
📄 `examples.basic_usage`
358+
📄 `examples.class_examples`
357359
📄 `examples.entry_points`
358360
📄 `examples.quickstart`
359361
📄 `project`

examples/class_examples.py

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,35 +7,34 @@
77
from code2docs.generators.api_reference_gen import ApiReferenceGenerator
88

99

10-
# --- ModuleDocsGenerator ---
11-
# Generate docs/modules/ — detailed per-module documentation.
12-
instance = ModuleDocsGenerator(config=..., result=...)
13-
1410
if __name__ == "__main__":
11+
# --- ModuleDocsGenerator ---
12+
# Generate docs/modules/ — detailed per-module documentation.
13+
instance = ModuleDocsGenerator(config=..., result=...)
1514
instance.generate_all()
1615
instance.write_all(output_dir=..., files=...)
1716

18-
# --- MarkdownFormatter ---
19-
# Helper for constructing Markdown documents.
20-
instance = MarkdownFormatter()
17+
# --- MarkdownFormatter ---
18+
# Helper for constructing Markdown documents.
19+
instance = MarkdownFormatter()
2120
instance.heading(text=..., level=...)
2221
instance.paragraph(text=...)
2322
instance.blockquote(text=...)
2423

25-
# --- ReadmeGenerator ---
26-
# Generate README.md from AnalysisResult.
27-
instance = ReadmeGenerator(config=..., result=...)
24+
# --- ReadmeGenerator ---
25+
# Generate README.md from AnalysisResult.
26+
instance = ReadmeGenerator(config=..., result=...)
2827
instance.generate()
2928
instance.write(path=..., content=...)
3029

31-
# --- ExamplesGenerator ---
32-
# Generate examples/ — usage examples from public API signatures.
33-
instance = ExamplesGenerator(config=..., result=...)
30+
# --- ExamplesGenerator ---
31+
# Generate examples/ — usage examples from public API signatures.
32+
instance = ExamplesGenerator(config=..., result=...)
3433
instance.generate_all()
3534
instance.write_all(output_dir=..., files=...)
3635

37-
# --- ApiReferenceGenerator ---
38-
# Generate docs/api/ — per-module API reference from signatures.
39-
instance = ApiReferenceGenerator(config=..., result=...)
36+
# --- ApiReferenceGenerator ---
37+
# Generate docs/api/ — per-module API reference from signatures.
38+
instance = ApiReferenceGenerator(config=..., result=...)
4039
instance.generate_all()
4140
instance.write_all(output_dir=..., files=...)

0 commit comments

Comments
 (0)