Skip to content

Commit 7c29c70

Browse files
refactor(docs): code analysis engine
stats: lines: "+658/-376 (net +282)" files: 20 complexity: "Stable complexity"
1 parent 30eca46 commit 7c29c70

23 files changed

+680
-379
lines changed

.github/workflows/ci.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main, develop]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
python-version: ["3.10", "3.11", "3.12", "3.13"]
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Set up Python ${{ matrix.python-version }}
20+
uses: actions/setup-python@v5
21+
with:
22+
python-version: ${{ matrix.python-version }}
23+
24+
- name: Install dependencies
25+
run: |
26+
python -m pip install --upgrade pip
27+
pip install -e ".[dev]"
28+
29+
- name: Run tests
30+
run: pytest tests/ -v --tb=short
31+
32+
- name: Run tests with coverage
33+
if: matrix.python-version == '3.12'
34+
run: pytest tests/ --cov=code2docs --cov-report=term-missing --cov-report=xml
35+
36+
- name: Upload coverage
37+
if: matrix.python-version == '3.12'
38+
uses: codecov/codecov-action@v4
39+
with:
40+
file: coverage.xml
41+
fail_ci_if_error: false

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,9 @@ marimo/_static/
208208
marimo/_lsp/
209209
__marimo__/
210210

211-
# code2docs
211+
# code2docs generated outputs
212212
.code2docs.state
213213
.code2docs.api_snapshot.json
214+
docs/
215+
examples/
216+
mkdocs.yml

CHANGELOG.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,25 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [0.2.1] - 2026-03-07
11+
12+
### Docs
13+
- Update project/README.md
14+
- Update project/context.md
15+
16+
### Other
17+
- Update .gitignore
18+
- Update VERSION
19+
- Update project/analysis.toon
20+
- Update project/calls.mmd
21+
- Update project/calls.png
22+
- Update project/compact_flow.mmd
23+
- Update project/compact_flow.png
24+
- Update project/dashboard.html
25+
- Update project/evolution.toon
26+
- Update project/flow.mmd
27+
- ... and 6 more files
28+
1029
## [0.1.7] - 2026-03-07
1130

1231
### Test

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# code2docs
22

3-
![version](https://img.shields.io/badge/version-0.1.7-blue) ![python](https://img.shields.io/badge/python-%3E%3D3.9-blue) ![docs](https://img.shields.io/badge/docs-auto--generated-blueviolet)
3+
![version](https://img.shields.io/badge/version-0.2.1-blue) ![python](https://img.shields.io/badge/python-%3E%3D3.9-blue) ![docs](https://img.shields.io/badge/docs-auto--generated-blueviolet)
44

55
> Auto-generate and sync project documentation from source code analysis.
66
@@ -140,7 +140,7 @@ code2docs can update only specific sections of an existing README using markers:
140140
```markdown
141141
<!-- code2docs:start --># code2docs
142142

143-
![version](https://img.shields.io/badge/version-0.1.7-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-153-green)
143+
![version](https://img.shields.io/badge/version-0.2.1-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-153-green)
144144
> **153** functions | **30** classes | **28** files | CC̄ = 0.0
145145

146146
## Installation

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.1.7
1+
0.2.1

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__ = "0.1.7"
8+
__version__ = "0.2.1"
99
__author__ = "Tom Sapletta"
1010

1111
from .config import Code2DocsConfig

project/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ When you run `code2llm ./ -f all`, the following files are created:
1010

1111
| File | Format | Purpose | Key Insights |
1212
|------|--------|---------|--------------|
13-
| `analysis.toon` | **TOON** | **🔥 Health diagnostics** - Complexity, god modules, coupling | 12 critical functions, 0 god modules |
13+
| `analysis.toon` | **TOON** | **🔥 Health diagnostics** - Complexity, god modules, coupling | 16 critical functions, 0 god modules |
1414
| `evolution.toon` | **TOON** | **📋 Refactoring queue** - Prioritized improvements | 0 refactoring actions needed |
1515
| `flow.toon` | **TOON** | **🔄 Data flow analysis** - Pipelines, contracts, types | Data dependencies and side effects |
1616
| `map.toon` | **TOON** | **🗺️ Structural map** - Modules, imports, signatures | Project architecture overview |
@@ -338,8 +338,8 @@ code2llm ./ -f yaml --separate-orphans
338338

339339
**Generated by**: `code2llm ./ -f all --readme`
340340
**Analysis Date**: 2026-03-07
341-
**Total Functions**: 127
342-
**Total Classes**: 25
343-
**Modules**: 24
341+
**Total Functions**: 154
342+
**Total Classes**: 30
343+
**Modules**: 31
344344

345345
For more information about code2llm, visit: https://github.com/tom-sapletta/code2llm

project/analysis.toon

Lines changed: 67 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
# code2llm | 24f 2544L | py:24 | 2026-03-07
2-
# CC̄=4.2 | critical:12/127 | dups:0 | cycles:1
1+
# code2llm | 28f 3095L | py:28 | 2026-03-07
2+
# CC̄=4.4 | critical:16/154 | dups:0 | cycles:1
33

4-
HEALTH[1]:
4+
HEALTH[3]:
5+
🟡 CC _render_per_module CC=18 (limit:15)
6+
🟡 CC _run_generate CC=17 (limit:15)
57
🟡 CC _parse_sections CC=15 (limit:15)
68

79
REFACTOR[2]:
8-
1. split 1 high-CC methods (CC>15)
10+
1. split 3 high-CC methods (CC>15)
911
2. break 1 circular dependencies
1012

1113
COUPLING:
@@ -17,25 +19,29 @@ COUPLING:
1719
CYCLES: 1
1820

1921
LAYERS:
20-
code2docs/ CC̄=4.2 ←in:0 →out:1
22+
code2docs/ CC̄=4.4 ←in:0 →out:1
23+
│ !! cli 269L 1C 10m CC=17 ←0
2124
│ readme_gen 260L 1C 14m CC=7 ←0
22-
│ ! cli 229L 1C 10m CC=13 ←0
2325
│ ! module_docs_gen 220L 1C 17m CC=12 ←0
2426
│ ! examples_gen 198L 1C 12m CC=12 ←0
27+
│ ! api_changelog_gen 196L 2C 9m CC=14 ←0
2528
│ ! architecture_gen 192L 1C 6m CC=12 ←0
2629
│ ! api_reference_gen 162L 1C 11m CC=13 ←0
2730
│ dependency_scanner 159L 3C 6m CC=8 ←0
2831
│ config 158L 5C 2m CC=7 ←1
32+
│ depgraph_gen 140L 1C 9m CC=9 ←0
2933
│ differ 125L 2C 7m CC=6 ←0
3034
│ changelog_gen 121L 2C 6m CC=6 ←0
3135
│ !! docstring_extractor 119L 2C 6m CC=15 ←0
3236
│ endpoint_detector 113L 2C 3m CC=5 ←0
37+
│ !! coverage_gen 85L 1C 5m CC=18 ←0
38+
│ mkdocs_gen 79L 1C 4m CC=8 ←0
3339
│ ! updater 77L 1C 2m CC=12 ←0
3440
│ watcher 75L 0C 1m CC=5 ←1
3541
│ markdown 73L 1C 13m CC=4 ←0
3642
│ toc 63L 0C 3m CC=6 ←0
43+
│ __init__ 53L 0C 1m CC=5 ←0
3744
│ ! badges 52L 0C 2m CC=11 ←1
38-
│ __init__ 42L 0C 1m CC=5 ←0
3945
│ project_scanner 42L 1C 4m CC=2 ←0
4046
│ __init__ 32L 0C 1m CC=4 ←0
4147
│ __init__ 13L 0C 0m CC=0.0 ←0
@@ -46,10 +52,12 @@ LAYERS:
4652

4753
DUPLICATES[0]: none
4854

49-
FUNCTIONS (CC≥10, 12 of 127):
55+
FUNCTIONS (CC≥10, 16 of 154):
56+
18.0 CoverageGenerator._render_per_module 4n 2exit loops+ret !! split
57+
17.0 _run_generate 33n 2exit cond+ret !! split
5058
15.0 DocstringExtractor._parse_sections 15n 1exit loops+cond !! split
59+
14.0 ApiChangelogGenerator._render 17n 4exit loops+cond+ret
5160
13.0 ApiReferenceGenerator._render_api_classes 14n 3exit loops+cond+ret
52-
13.0 _run_generate 25n 2exit cond+ret
5361
12.0 Updater.apply 14n 1exit loops+cond
5462
12.0 ModuleDocsGenerator._render_classes_section 14n 3exit loops+cond+ret
5563
12.0 ExamplesGenerator._generate_class_examples 10n 2exit loops+cond+ret
@@ -59,63 +67,61 @@ FUNCTIONS (CC≥10, 12 of 127):
5967
11.0 ArchitectureGenerator._generate_class_diagram 12n 2exit loops+cond+ret
6068
10.0 ModuleDocsGenerator._render_dependencies_section 12n 3exit loops+cond+ret
6169
10.0 ExamplesGenerator._generate_basic_usage 3n 2exit ret
70+
10.0 ApiChangelogGenerator._diff_functions 9n 1exit loops+cond
71+
10.0 ApiChangelogGenerator._diff_classes 15n 1exit loops+cond
6272

6373
summary:
64-
critical(≥10): 12 | high(5-10): 33 | medium(2-5): 54 | low(<2): 28
65-
9% CC≥10 35% CC≥5
74+
critical(≥10): 16 | high(5-10): 39 | medium(2-5): 65 | low(<2): 34
75+
10% CC≥10 36% CC≥5
6676

6777
HOTSPOTS:
68-
#1 _run_generate fan=24 "calls 24 functions"
78+
#1 _run_generate fan=34 "calls 34 functions"
6979
#2 start_watcher fan=22 "calls 22 functions"
7080
#3 Updater.apply fan=20 "Updater method, fan-out=20"
7181
#4 Code2DocsConfig.from_yaml fan=15 "Code2DocsConfig method, fan-out=15"
72-
#5 ApiReferenceGenerator._render_api_classes fan=11 "ApiReferenceGenerator method, fan-out=11"
73-
#6 ArchitectureGenerator.generate fan=11 "ArchitectureGenerator method, fan-out=11"
74-
#7 DocstringExtractor._parse_sections fan=11 "DocstringExtractor method, fan-out=11"
75-
#8 Differ.detect_changes fan=10 "Differ method, fan-out=10"
76-
#9 init fan=10 "calls 10 functions"
77-
#10 EndpointDetector._scan_django_urls fan=10 "EndpointDetector method, fan-out=10"
82+
#5 ApiChangelogGenerator._diff_classes fan=12 "ApiChangelogGenerator method, fan-out=12"
83+
#6 generate_docs fan=11 "calls 11 functions"
84+
#7 ApiReferenceGenerator._render_api_classes fan=11 "ApiReferenceGenerator method, fan-out=11"
85+
#8 ArchitectureGenerator.generate fan=11 "ArchitectureGenerator method, fan-out=11"
86+
#9 DocstringExtractor._parse_sections fan=11 "DocstringExtractor method, fan-out=11"
87+
#10 Differ.detect_changes fan=10 "Differ method, fan-out=10"
7888

7989
CLASSES:
8090
ModuleDocsGenerator ████████████████████████ 17m CC̄=4.6 max=12
8191
MarkdownFormatter ██████████████████ 13m CC̄=1.2 max=4
8292
ReadmeGenerator ██████████████████ 13m CC̄=3.9 max=7
8393
ExamplesGenerator ████████████████ 12m CC̄=6.0 max=12
8494
ApiReferenceGenerator ███████████████ 11m CC̄=4.0 max=13
95+
DepGraphGenerator ████████████ 9m CC̄=3.9 max=9
96+
ApiChangelogGenerator ████████████ 9m CC̄=5.4 max=14
8597
Differ ████████ 6m CC̄=4.0 max=6
8698
ChangelogGenerator ████████ 6m CC̄=3.5 max=6
8799
ArchitectureGenerator ████████ 6m CC̄=7.8 max=12
88-
DocstringExtractor ████████ 6m CC̄=6.2 max=15 !!
89100
DependencyScanner ████████ 6m CC̄=4.5 max=8
101+
DocstringExtractor ████████ 6m CC̄=6.2 max=15 !!
102+
CoverageGenerator ███████ 5m CC̄=6.4 max=18 !!
103+
MkDocsGenerator █████ 4m CC̄=3.0 max=8
90104
ProjectScanner ████ 3m CC̄=1.3 max=2
91105
EndpointDetector ████ 3m CC̄=4.0 max=5
92106
Updater ██ 2m CC̄=7.0 max=12
93107
Code2DocsConfig ██ 2m CC̄=4.0 max=7
94108
ChangeInfo █ 1m CC̄=1.0 max=1
95109
DefaultGroup █ 1m CC̄=4.0 max=4
96110
ChangelogEntry 0m CC̄=0.0 max=0.0
111+
ApiChange 0m CC̄=0.0 max=0.0
97112
ReadmeConfig 0m CC̄=0.0 max=0.0
98113
DocsConfig 0m CC̄=0.0 max=0.0
99114
ExamplesConfig 0m CC̄=0.0 max=0.0
100115
SyncConfig 0m CC̄=0.0 max=0.0
101-
DocstringInfo 0m CC̄=0.0 max=0.0
102116
DependencyInfo 0m CC̄=0.0 max=0.0
103117
ProjectDependencies 0m CC̄=0.0 max=0.0
118+
DocstringInfo 0m CC̄=0.0 max=0.0
104119
Endpoint 0m CC̄=0.0 max=0.0
105120

106121
D:
107-
code2docs/analyzers/docstring_extractor.py:
108-
e: DocstringInfo,DocstringExtractor
109-
DocstringInfo # Parsed docstring with sections....
110-
DocstringExtractor # Extract and parse docstrings from AnalysisResult....
111-
extract_all(1) CC=5.0
112-
→ parse(1) CC=2.0
113-
→ _extract_summary(0) CC=2.0
114-
→ _parse_sections(2) CC=15.0 !
115-
→ _classify_section(0) CC=5.0
116-
code2docs/generators/api_reference_gen.py:
117-
e: ApiReferenceGenerator
118-
ApiReferenceGenerator # Generate docs/api/ — per-module API reference from signature...
122+
code2docs/generators/coverage_gen.py:
123+
e: CoverageGenerator
124+
CoverageGenerator # Generate docs/coverage.md — docstring coverage report....
119125
__init__(2) CC=1.0
120126
code2docs/cli.py:
121127
e: DefaultGroup,main,generate,sync,watch,init,_load_config,_run_generate,_run_sync,_run_watch
@@ -131,6 +137,24 @@ D:
131137
_run_generate(project_path,config,readme_only,dry_run)
132138
_run_sync(project_path,config,dry_run)
133139
_run_watch(project_path,config)
140+
code2docs/analyzers/docstring_extractor.py:
141+
e: DocstringInfo,DocstringExtractor
142+
DocstringInfo # Parsed docstring with sections....
143+
DocstringExtractor # Extract and parse docstrings from AnalysisResult....
144+
extract_all(1) CC=5.0
145+
→ parse(1) CC=2.0
146+
→ _extract_summary(0) CC=2.0
147+
→ _parse_sections(2) CC=15.0 !
148+
→ _classify_section(0) CC=5.0
149+
code2docs/generators/api_changelog_gen.py:
150+
e: ApiChange,ApiChangelogGenerator
151+
ApiChange # A single API change between two analysis snapshots....
152+
ApiChangelogGenerator # Generate API changelog by diffing current analysis with a sa...
153+
__init__(2) CC=1.0
154+
code2docs/generators/api_reference_gen.py:
155+
e: ApiReferenceGenerator
156+
ApiReferenceGenerator # Generate docs/api/ — per-module API reference from signature...
157+
__init__(2) CC=1.0
134158
code2docs/sync/updater.py:
135159
e: Updater
136160
Updater # Apply selective documentation updates based on detected chan...
@@ -151,6 +175,14 @@ D:
151175
e: generate_badges,_make_badge
152176
generate_badges(project_name,badge_types,stats,deps)
153177
_make_badge(badge_type,project_name,stats,deps)
178+
code2docs/generators/depgraph_gen.py:
179+
e: DepGraphGenerator
180+
DepGraphGenerator # Generate docs/dependency-graph.md with Mermaid diagrams....
181+
__init__(2) CC=1.0
182+
code2docs/generators/mkdocs_gen.py:
183+
e: MkDocsGenerator
184+
MkDocsGenerator # Generate mkdocs.yml from the docs/ directory structure....
185+
__init__(2) CC=1.0
154186
code2docs/analyzers/dependency_scanner.py:
155187
e: DependencyInfo,ProjectDependencies,DependencyScanner
156188
DependencyInfo # Information about a project dependency....
@@ -217,7 +249,10 @@ D:
217249
__init__(1) CC=2.0
218250
→ _build_llm_config(0) CC=1.0
219251
analyze_and_document(project_path,config)
252+
examples/entry_points.py:
253+
examples/class_examples.py:
220254
code2docs/__main__.py:
255+
examples/basic_usage.py:
221256
code2docs/sync/__init__.py:
222257
code2docs/formatters/__init__.py:
223258
code2docs/analyzers/__init__.py:

project/calls.mmd

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
flowchart LR
22
subgraph code2docs_cli
3-
code2docs__cli___run_sync["_run_sync"]
43
code2docs__cli__watch["watch"]
5-
code2docs__cli___run_generate["_run_generate"]
6-
code2docs__cli__sync["sync"]
7-
code2docs__cli___load_config["_load_config"]
4+
code2docs__cli___run_sync["_run_sync"]
85
code2docs__cli__generate["generate"]
6+
code2docs__cli___load_config["_load_config"]
97
code2docs__cli___run_watch["_run_watch"]
8+
code2docs__cli__sync["sync"]
9+
code2docs__cli___run_generate["_run_generate"]
1010
end
1111
subgraph code2docs_config
1212
code2docs__config__Code2DocsConfig__from_yaml["from_yaml"]
1313
end
1414
subgraph code2docs_formatters
15+
code2docs__formatters__toc__extract_headings["extract_headings"]
1516
code2docs__formatters__badges___make_badge["_make_badge"]
17+
code2docs__formatters__badges__generate_badges["generate_badges"]
1618
code2docs__formatters__toc__generate_toc["generate_toc"]
1719
code2docs__formatters__toc___slugify["_slugify"]
18-
code2docs__formatters__badges__generate_badges["generate_badges"]
19-
code2docs__formatters__toc__extract_headings["extract_headings"]
2020
end
2121
subgraph code2docs_generators
2222
code2docs___build_context["_build_context"]

project/calls.png

55 Bytes
Loading

0 commit comments

Comments
 (0)