code2docs 0.1.4__tar.gz → 0.1.6__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {code2docs-0.1.4 → code2docs-0.1.6}/PKG-INFO +111 -4
- code2docs-0.1.6/README.md +295 -0
- {code2docs-0.1.4 → code2docs-0.1.6}/code2docs/__init__.py +1 -1
- {code2docs-0.1.4 → code2docs-0.1.6}/code2docs/cli.py +43 -3
- {code2docs-0.1.4 → code2docs-0.1.6}/code2docs/generators/__init__.py +11 -0
- code2docs-0.1.6/code2docs/generators/api_changelog_gen.py +196 -0
- code2docs-0.1.6/code2docs/templates/module_doc.md.j2 +86 -0
- {code2docs-0.1.4 → code2docs-0.1.6}/code2docs.egg-info/PKG-INFO +111 -4
- {code2docs-0.1.4 → code2docs-0.1.6}/code2docs.egg-info/SOURCES.txt +2 -0
- {code2docs-0.1.4 → code2docs-0.1.6}/pyproject.toml +1 -1
- {code2docs-0.1.4 → code2docs-0.1.6}/tests/test_generators.py +184 -0
- code2docs-0.1.4/README.md +0 -188
- {code2docs-0.1.4 → code2docs-0.1.6}/LICENSE +0 -0
- {code2docs-0.1.4 → code2docs-0.1.6}/code2docs/__main__.py +0 -0
- {code2docs-0.1.4 → code2docs-0.1.6}/code2docs/analyzers/__init__.py +0 -0
- {code2docs-0.1.4 → code2docs-0.1.6}/code2docs/analyzers/dependency_scanner.py +0 -0
- {code2docs-0.1.4 → code2docs-0.1.6}/code2docs/analyzers/docstring_extractor.py +0 -0
- {code2docs-0.1.4 → code2docs-0.1.6}/code2docs/analyzers/endpoint_detector.py +0 -0
- {code2docs-0.1.4 → code2docs-0.1.6}/code2docs/analyzers/project_scanner.py +0 -0
- {code2docs-0.1.4 → code2docs-0.1.6}/code2docs/config.py +0 -0
- {code2docs-0.1.4 → code2docs-0.1.6}/code2docs/formatters/__init__.py +0 -0
- {code2docs-0.1.4 → code2docs-0.1.6}/code2docs/formatters/badges.py +0 -0
- {code2docs-0.1.4 → code2docs-0.1.6}/code2docs/formatters/markdown.py +0 -0
- {code2docs-0.1.4 → code2docs-0.1.6}/code2docs/formatters/toc.py +0 -0
- {code2docs-0.1.4 → code2docs-0.1.6}/code2docs/generators/api_reference_gen.py +0 -0
- {code2docs-0.1.4 → code2docs-0.1.6}/code2docs/generators/architecture_gen.py +0 -0
- {code2docs-0.1.4 → code2docs-0.1.6}/code2docs/generators/changelog_gen.py +0 -0
- {code2docs-0.1.4 → code2docs-0.1.6}/code2docs/generators/coverage_gen.py +0 -0
- {code2docs-0.1.4 → code2docs-0.1.6}/code2docs/generators/depgraph_gen.py +0 -0
- {code2docs-0.1.4 → code2docs-0.1.6}/code2docs/generators/examples_gen.py +0 -0
- {code2docs-0.1.4 → code2docs-0.1.6}/code2docs/generators/mkdocs_gen.py +0 -0
- {code2docs-0.1.4 → code2docs-0.1.6}/code2docs/generators/module_docs_gen.py +0 -0
- {code2docs-0.1.4 → code2docs-0.1.6}/code2docs/generators/readme_gen.py +0 -0
- {code2docs-0.1.4 → code2docs-0.1.6}/code2docs/sync/__init__.py +0 -0
- {code2docs-0.1.4 → code2docs-0.1.6}/code2docs/sync/differ.py +0 -0
- {code2docs-0.1.4 → code2docs-0.1.6}/code2docs/sync/updater.py +0 -0
- {code2docs-0.1.4 → code2docs-0.1.6}/code2docs/sync/watcher.py +0 -0
- {code2docs-0.1.4 → code2docs-0.1.6}/code2docs/templates/api_module.md.j2 +0 -0
- {code2docs-0.1.4 → code2docs-0.1.6}/code2docs/templates/architecture.md.j2 +0 -0
- {code2docs-0.1.4 → code2docs-0.1.6}/code2docs/templates/example_usage.py.j2 +0 -0
- {code2docs-0.1.4 → code2docs-0.1.6}/code2docs/templates/index.md.j2 +0 -0
- {code2docs-0.1.4 → code2docs-0.1.6}/code2docs/templates/readme.md.j2 +0 -0
- {code2docs-0.1.4 → code2docs-0.1.6}/code2docs.egg-info/dependency_links.txt +0 -0
- {code2docs-0.1.4 → code2docs-0.1.6}/code2docs.egg-info/entry_points.txt +0 -0
- {code2docs-0.1.4 → code2docs-0.1.6}/code2docs.egg-info/requires.txt +0 -0
- {code2docs-0.1.4 → code2docs-0.1.6}/code2docs.egg-info/top_level.txt +0 -0
- {code2docs-0.1.4 → code2docs-0.1.6}/setup.cfg +0 -0
- {code2docs-0.1.4 → code2docs-0.1.6}/tests/test_analyzers.py +0 -0
- {code2docs-0.1.4 → code2docs-0.1.6}/tests/test_code2docs.py +0 -0
- {code2docs-0.1.4 → code2docs-0.1.6}/tests/test_config.py +0 -0
- {code2docs-0.1.4 → code2docs-0.1.6}/tests/test_formatters.py +0 -0
- {code2docs-0.1.4 → code2docs-0.1.6}/tests/test_sync.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: code2docs
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.6
|
|
4
4
|
Summary: Auto-generate and sync project documentation from source code analysis
|
|
5
5
|
Author-email: Tom Sapletta <tom@sapletta.com>
|
|
6
6
|
License-Expression: Apache-2.0
|
|
@@ -40,7 +40,7 @@ Dynamic: license-file
|
|
|
40
40
|
|
|
41
41
|
# code2docs
|
|
42
42
|
|
|
43
|
-
  
|
|
44
44
|
|
|
45
45
|
> Auto-generate and sync project documentation from source code analysis.
|
|
46
46
|
|
|
@@ -178,8 +178,115 @@ sync:
|
|
|
178
178
|
code2docs can update only specific sections of an existing README using markers:
|
|
179
179
|
|
|
180
180
|
```markdown
|
|
181
|
-
<!-- code2docs:start
|
|
182
|
-
|
|
181
|
+
<!-- code2docs:start --># code2docs
|
|
182
|
+
|
|
183
|
+
   
|
|
184
|
+
> **153** functions | **30** classes | **28** files | CC̄ = 0.0
|
|
185
|
+
|
|
186
|
+
## Installation
|
|
187
|
+
|
|
188
|
+
```bash
|
|
189
|
+
pip install code2docs
|
|
190
|
+
```
|
|
191
|
+
Requires Python >=3.9
|
|
192
|
+
|
|
193
|
+
### Dependencies
|
|
194
|
+
|
|
195
|
+
- `code2llm` >=0.5.0
|
|
196
|
+
- `jinja2` >=3.1
|
|
197
|
+
- `click` >=8.0
|
|
198
|
+
- `pyyaml` >=6.0
|
|
199
|
+
|
|
200
|
+
## Quick Start
|
|
201
|
+
|
|
202
|
+
```python
|
|
203
|
+
# Entry point: code2docs.__getattr__
|
|
204
|
+
# Entry point: code2docs.sync.updater.Updater.__init__
|
|
205
|
+
# Entry point: code2docs.sync.updater.Updater.apply
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
## API Overview
|
|
209
|
+
|
|
210
|
+
### Classes
|
|
211
|
+
|
|
212
|
+
- **`Updater`** — Apply selective documentation updates based on detected changes.
|
|
213
|
+
- **`MarkdownFormatter`** — Helper for constructing Markdown documents.
|
|
214
|
+
- **`ReadmeGenerator`** — Generate README.md from AnalysisResult.
|
|
215
|
+
- **`ChangeInfo`** — Describes a detected change.
|
|
216
|
+
- **`Differ`** — Detect changes between current source and previous state.
|
|
217
|
+
- **`CoverageGenerator`** — Generate docs/coverage.md — docstring coverage report.
|
|
218
|
+
- **`DepGraphGenerator`** — Generate docs/dependency-graph.md with Mermaid diagrams.
|
|
219
|
+
- **`ModuleDocsGenerator`** — Generate docs/modules/ — detailed per-module documentation.
|
|
220
|
+
- **`ApiReferenceGenerator`** — Generate docs/api/ — per-module API reference from signatures.
|
|
221
|
+
- **`ChangelogEntry`** — A single changelog entry.
|
|
222
|
+
- **`ChangelogGenerator`** — Generate CHANGELOG.md from git log and analysis diff.
|
|
223
|
+
- **`MkDocsGenerator`** — Generate mkdocs.yml from the docs/ directory structure.
|
|
224
|
+
- **`ExamplesGenerator`** — Generate examples/ — usage examples from public API signatures.
|
|
225
|
+
- **`ApiChange`** — A single API change between two analysis snapshots.
|
|
226
|
+
- **`ApiChangelogGenerator`** — Generate API changelog by diffing current analysis with a saved snapshot.
|
|
227
|
+
- **`ArchitectureGenerator`** — Generate docs/architecture.md — architecture overview with diagrams.
|
|
228
|
+
- **`DefaultGroup`** — Click Group that routes unknown subcommands to 'generate'.
|
|
229
|
+
- **`ReadmeConfig`** — Configuration for README generation.
|
|
230
|
+
- **`DocsConfig`** — Configuration for docs/ generation.
|
|
231
|
+
- **`ExamplesConfig`** — Configuration for examples/ generation.
|
|
232
|
+
- **`SyncConfig`** — Configuration for synchronization.
|
|
233
|
+
- **`Code2DocsConfig`** — Main configuration for code2docs.
|
|
234
|
+
- **`ProjectScanner`** — Wraps code2llm's ProjectAnalyzer with code2docs-specific defaults.
|
|
235
|
+
- **`DependencyInfo`** — Information about a project dependency.
|
|
236
|
+
- **`ProjectDependencies`** — All detected project dependencies.
|
|
237
|
+
- **`DependencyScanner`** — Scan and parse project dependency files.
|
|
238
|
+
- **`DocstringInfo`** — Parsed docstring with sections.
|
|
239
|
+
- **`DocstringExtractor`** — Extract and parse docstrings from AnalysisResult.
|
|
240
|
+
- **`Endpoint`** — Represents a detected web endpoint.
|
|
241
|
+
- **`EndpointDetector`** — Detects web endpoints from decorator patterns in source code.
|
|
242
|
+
|
|
243
|
+
### Functions
|
|
244
|
+
|
|
245
|
+
- `start_watcher(project_path, config)` — Start watching project for file changes and auto-resync docs.
|
|
246
|
+
- `generate_badges(project_name, badge_types, stats, deps)` — Generate shields.io badge Markdown strings.
|
|
247
|
+
- `generate_toc(markdown_content, max_depth)` — Generate a table of contents from Markdown headings.
|
|
248
|
+
- `extract_headings(content, max_depth)` — Extract headings from Markdown content.
|
|
249
|
+
- `generate_readme(project_path, output, sections, sync_markers, config)` — Convenience function to generate a README.
|
|
250
|
+
- `generate_docs(project_path, config)` — High-level function to generate all documentation.
|
|
251
|
+
- `main()` — code2docs — Auto-generate project documentation from source code.
|
|
252
|
+
- `generate(project_path, config_path, readme_only, sections, output, verbose, dry_run)` — Generate documentation (default command).
|
|
253
|
+
- `sync(project_path, config_path, verbose, dry_run)` — Synchronize documentation with source code changes.
|
|
254
|
+
- `watch(project_path, config_path, verbose)` — Watch for file changes and auto-regenerate docs.
|
|
255
|
+
- `init(project_path, output)` — Initialize code2docs.yaml configuration file.
|
|
256
|
+
- `analyze_and_document(project_path, config)` — Convenience function: analyze a project in one call.
|
|
257
|
+
|
|
258
|
+
## Project Structure
|
|
259
|
+
|
|
260
|
+
📦 `code2docs` (1 functions)
|
|
261
|
+
📄 `code2docs.__main__`
|
|
262
|
+
📦 `code2docs.analyzers`
|
|
263
|
+
📄 `code2docs.analyzers.dependency_scanner` (6 functions, 3 classes)
|
|
264
|
+
📄 `code2docs.analyzers.docstring_extractor` (6 functions, 2 classes)
|
|
265
|
+
📄 `code2docs.analyzers.endpoint_detector` (3 functions, 2 classes)
|
|
266
|
+
📄 `code2docs.analyzers.project_scanner` (4 functions, 1 classes)
|
|
267
|
+
📄 `code2docs.cli` (10 functions, 1 classes)
|
|
268
|
+
📄 `code2docs.config` (2 functions, 5 classes)
|
|
269
|
+
📦 `code2docs.formatters`
|
|
270
|
+
📄 `code2docs.formatters.badges` (2 functions)
|
|
271
|
+
📄 `code2docs.formatters.markdown` (13 functions, 1 classes)
|
|
272
|
+
📄 `code2docs.formatters.toc` (3 functions)
|
|
273
|
+
📦 `code2docs.generators` (1 functions)
|
|
274
|
+
📄 `code2docs.generators.api_changelog_gen` (9 functions, 2 classes)
|
|
275
|
+
📄 `code2docs.generators.api_reference_gen` (11 functions, 1 classes)
|
|
276
|
+
📄 `code2docs.generators.architecture_gen` (6 functions, 1 classes)
|
|
277
|
+
📄 `code2docs.generators.changelog_gen` (6 functions, 2 classes)
|
|
278
|
+
📄 `code2docs.generators.coverage_gen` (5 functions, 1 classes)
|
|
279
|
+
📄 `code2docs.generators.depgraph_gen` (8 functions, 1 classes)
|
|
280
|
+
📄 `code2docs.generators.examples_gen` (12 functions, 1 classes)
|
|
281
|
+
📄 `code2docs.generators.mkdocs_gen` (4 functions, 1 classes)
|
|
282
|
+
📄 `code2docs.generators.module_docs_gen` (17 functions, 1 classes)
|
|
283
|
+
📄 `code2docs.generators.readme_gen` (14 functions, 1 classes)
|
|
284
|
+
📦 `code2docs.sync`
|
|
285
|
+
📄 `code2docs.sync.differ` (7 functions, 2 classes)
|
|
286
|
+
📄 `code2docs.sync.updater` (2 functions, 1 classes)
|
|
287
|
+
📄 `code2docs.sync.watcher` (1 functions)
|
|
288
|
+
|
|
289
|
+
|
|
183
290
|
<!-- code2docs:end -->
|
|
184
291
|
```
|
|
185
292
|
|
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
# code2docs
|
|
2
|
+
|
|
3
|
+
  
|
|
4
|
+
|
|
5
|
+
> Auto-generate and sync project documentation from source code analysis.
|
|
6
|
+
|
|
7
|
+
**code2docs** uses [code2llm](https://github.com/wronai/code2llm)'s `AnalysisResult` to produce human-readable documentation: README.md, API references, module docs, usage examples, and architecture diagrams.
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
code2llm → AnalysisResult → .toon / .mmd / context.md (for LLM)
|
|
11
|
+
code2docs → AnalysisResult → README.md / docs/ / examples/ (for humans)
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
pip install code2docs
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Or from source:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
git clone https://github.com/wronai/code2docs
|
|
24
|
+
cd code2docs
|
|
25
|
+
pip install -e .
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### Optional extras
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
pip install code2docs[watch] # file watcher (watchdog)
|
|
32
|
+
pip install code2docs[mkdocs] # MkDocs integration
|
|
33
|
+
pip install code2docs[dev] # development tools
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Quick Start
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
# Generate full documentation for a project
|
|
40
|
+
code2docs ./my-project
|
|
41
|
+
|
|
42
|
+
# Generate only README
|
|
43
|
+
code2docs ./my-project --readme-only
|
|
44
|
+
|
|
45
|
+
# Sync (regenerate only changed modules)
|
|
46
|
+
code2docs sync ./my-project
|
|
47
|
+
|
|
48
|
+
# Watch mode (auto-resync on file changes)
|
|
49
|
+
code2docs watch ./my-project
|
|
50
|
+
|
|
51
|
+
# Initialize config file
|
|
52
|
+
code2docs init ./my-project
|
|
53
|
+
|
|
54
|
+
# Dry-run (show what would be generated)
|
|
55
|
+
code2docs ./my-project --dry-run
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Python API
|
|
59
|
+
|
|
60
|
+
```python
|
|
61
|
+
from code2docs import generate_readme, generate_docs, Code2DocsConfig
|
|
62
|
+
|
|
63
|
+
# Generate README
|
|
64
|
+
generate_readme("./my-project", output="README.md")
|
|
65
|
+
|
|
66
|
+
# Generate full docs with custom config
|
|
67
|
+
config = Code2DocsConfig(project_name="mylib", verbose=True)
|
|
68
|
+
docs = generate_docs("./my-project", config=config)
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Generated Output
|
|
72
|
+
|
|
73
|
+
```
|
|
74
|
+
<project>/
|
|
75
|
+
├── README.md # Main README (auto-generated sections)
|
|
76
|
+
├── docs/
|
|
77
|
+
│ ├── index.md # Documentation index
|
|
78
|
+
│ ├── architecture.md # Architecture + Mermaid diagrams
|
|
79
|
+
│ ├── api/
|
|
80
|
+
│ │ ├── index.md # API overview
|
|
81
|
+
│ │ ├── module_analyzer.md # Per-module API reference
|
|
82
|
+
│ │ └── ...
|
|
83
|
+
│ └── modules/
|
|
84
|
+
│ ├── analyzer.md # Detailed module documentation
|
|
85
|
+
│ └── ...
|
|
86
|
+
├── examples/
|
|
87
|
+
│ ├── basic_usage.py # Auto-generated usage example
|
|
88
|
+
│ ├── class_examples.py # Class usage examples
|
|
89
|
+
│ └── ...
|
|
90
|
+
└── code2docs.yaml # Generator configuration
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Configuration
|
|
94
|
+
|
|
95
|
+
Create `code2docs.yaml` in your project root (or run `code2docs init`):
|
|
96
|
+
|
|
97
|
+
```yaml
|
|
98
|
+
project:
|
|
99
|
+
name: my-project
|
|
100
|
+
source: ./
|
|
101
|
+
output: ./docs/
|
|
102
|
+
|
|
103
|
+
readme:
|
|
104
|
+
sections:
|
|
105
|
+
- overview
|
|
106
|
+
- install
|
|
107
|
+
- quickstart
|
|
108
|
+
- api
|
|
109
|
+
- structure
|
|
110
|
+
- endpoints
|
|
111
|
+
badges:
|
|
112
|
+
- version
|
|
113
|
+
- python
|
|
114
|
+
- coverage
|
|
115
|
+
- complexity
|
|
116
|
+
sync_markers: true
|
|
117
|
+
|
|
118
|
+
docs:
|
|
119
|
+
api_reference: true
|
|
120
|
+
module_docs: true
|
|
121
|
+
architecture: true
|
|
122
|
+
changelog: true
|
|
123
|
+
|
|
124
|
+
examples:
|
|
125
|
+
auto_generate: true
|
|
126
|
+
from_entry_points: true
|
|
127
|
+
|
|
128
|
+
sync:
|
|
129
|
+
strategy: markers # markers | full | git-diff
|
|
130
|
+
watch: false
|
|
131
|
+
ignore:
|
|
132
|
+
- "tests/"
|
|
133
|
+
- "__pycache__"
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## Sync Markers
|
|
137
|
+
|
|
138
|
+
code2docs can update only specific sections of an existing README using markers:
|
|
139
|
+
|
|
140
|
+
```markdown
|
|
141
|
+
<!-- code2docs:start --># code2docs
|
|
142
|
+
|
|
143
|
+
   
|
|
144
|
+
> **153** functions | **30** classes | **28** files | CC̄ = 0.0
|
|
145
|
+
|
|
146
|
+
## Installation
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
pip install code2docs
|
|
150
|
+
```
|
|
151
|
+
Requires Python >=3.9
|
|
152
|
+
|
|
153
|
+
### Dependencies
|
|
154
|
+
|
|
155
|
+
- `code2llm` >=0.5.0
|
|
156
|
+
- `jinja2` >=3.1
|
|
157
|
+
- `click` >=8.0
|
|
158
|
+
- `pyyaml` >=6.0
|
|
159
|
+
|
|
160
|
+
## Quick Start
|
|
161
|
+
|
|
162
|
+
```python
|
|
163
|
+
# Entry point: code2docs.__getattr__
|
|
164
|
+
# Entry point: code2docs.sync.updater.Updater.__init__
|
|
165
|
+
# Entry point: code2docs.sync.updater.Updater.apply
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
## API Overview
|
|
169
|
+
|
|
170
|
+
### Classes
|
|
171
|
+
|
|
172
|
+
- **`Updater`** — Apply selective documentation updates based on detected changes.
|
|
173
|
+
- **`MarkdownFormatter`** — Helper for constructing Markdown documents.
|
|
174
|
+
- **`ReadmeGenerator`** — Generate README.md from AnalysisResult.
|
|
175
|
+
- **`ChangeInfo`** — Describes a detected change.
|
|
176
|
+
- **`Differ`** — Detect changes between current source and previous state.
|
|
177
|
+
- **`CoverageGenerator`** — Generate docs/coverage.md — docstring coverage report.
|
|
178
|
+
- **`DepGraphGenerator`** — Generate docs/dependency-graph.md with Mermaid diagrams.
|
|
179
|
+
- **`ModuleDocsGenerator`** — Generate docs/modules/ — detailed per-module documentation.
|
|
180
|
+
- **`ApiReferenceGenerator`** — Generate docs/api/ — per-module API reference from signatures.
|
|
181
|
+
- **`ChangelogEntry`** — A single changelog entry.
|
|
182
|
+
- **`ChangelogGenerator`** — Generate CHANGELOG.md from git log and analysis diff.
|
|
183
|
+
- **`MkDocsGenerator`** — Generate mkdocs.yml from the docs/ directory structure.
|
|
184
|
+
- **`ExamplesGenerator`** — Generate examples/ — usage examples from public API signatures.
|
|
185
|
+
- **`ApiChange`** — A single API change between two analysis snapshots.
|
|
186
|
+
- **`ApiChangelogGenerator`** — Generate API changelog by diffing current analysis with a saved snapshot.
|
|
187
|
+
- **`ArchitectureGenerator`** — Generate docs/architecture.md — architecture overview with diagrams.
|
|
188
|
+
- **`DefaultGroup`** — Click Group that routes unknown subcommands to 'generate'.
|
|
189
|
+
- **`ReadmeConfig`** — Configuration for README generation.
|
|
190
|
+
- **`DocsConfig`** — Configuration for docs/ generation.
|
|
191
|
+
- **`ExamplesConfig`** — Configuration for examples/ generation.
|
|
192
|
+
- **`SyncConfig`** — Configuration for synchronization.
|
|
193
|
+
- **`Code2DocsConfig`** — Main configuration for code2docs.
|
|
194
|
+
- **`ProjectScanner`** — Wraps code2llm's ProjectAnalyzer with code2docs-specific defaults.
|
|
195
|
+
- **`DependencyInfo`** — Information about a project dependency.
|
|
196
|
+
- **`ProjectDependencies`** — All detected project dependencies.
|
|
197
|
+
- **`DependencyScanner`** — Scan and parse project dependency files.
|
|
198
|
+
- **`DocstringInfo`** — Parsed docstring with sections.
|
|
199
|
+
- **`DocstringExtractor`** — Extract and parse docstrings from AnalysisResult.
|
|
200
|
+
- **`Endpoint`** — Represents a detected web endpoint.
|
|
201
|
+
- **`EndpointDetector`** — Detects web endpoints from decorator patterns in source code.
|
|
202
|
+
|
|
203
|
+
### Functions
|
|
204
|
+
|
|
205
|
+
- `start_watcher(project_path, config)` — Start watching project for file changes and auto-resync docs.
|
|
206
|
+
- `generate_badges(project_name, badge_types, stats, deps)` — Generate shields.io badge Markdown strings.
|
|
207
|
+
- `generate_toc(markdown_content, max_depth)` — Generate a table of contents from Markdown headings.
|
|
208
|
+
- `extract_headings(content, max_depth)` — Extract headings from Markdown content.
|
|
209
|
+
- `generate_readme(project_path, output, sections, sync_markers, config)` — Convenience function to generate a README.
|
|
210
|
+
- `generate_docs(project_path, config)` — High-level function to generate all documentation.
|
|
211
|
+
- `main()` — code2docs — Auto-generate project documentation from source code.
|
|
212
|
+
- `generate(project_path, config_path, readme_only, sections, output, verbose, dry_run)` — Generate documentation (default command).
|
|
213
|
+
- `sync(project_path, config_path, verbose, dry_run)` — Synchronize documentation with source code changes.
|
|
214
|
+
- `watch(project_path, config_path, verbose)` — Watch for file changes and auto-regenerate docs.
|
|
215
|
+
- `init(project_path, output)` — Initialize code2docs.yaml configuration file.
|
|
216
|
+
- `analyze_and_document(project_path, config)` — Convenience function: analyze a project in one call.
|
|
217
|
+
|
|
218
|
+
## Project Structure
|
|
219
|
+
|
|
220
|
+
📦 `code2docs` (1 functions)
|
|
221
|
+
📄 `code2docs.__main__`
|
|
222
|
+
📦 `code2docs.analyzers`
|
|
223
|
+
📄 `code2docs.analyzers.dependency_scanner` (6 functions, 3 classes)
|
|
224
|
+
📄 `code2docs.analyzers.docstring_extractor` (6 functions, 2 classes)
|
|
225
|
+
📄 `code2docs.analyzers.endpoint_detector` (3 functions, 2 classes)
|
|
226
|
+
📄 `code2docs.analyzers.project_scanner` (4 functions, 1 classes)
|
|
227
|
+
📄 `code2docs.cli` (10 functions, 1 classes)
|
|
228
|
+
📄 `code2docs.config` (2 functions, 5 classes)
|
|
229
|
+
📦 `code2docs.formatters`
|
|
230
|
+
📄 `code2docs.formatters.badges` (2 functions)
|
|
231
|
+
📄 `code2docs.formatters.markdown` (13 functions, 1 classes)
|
|
232
|
+
📄 `code2docs.formatters.toc` (3 functions)
|
|
233
|
+
📦 `code2docs.generators` (1 functions)
|
|
234
|
+
📄 `code2docs.generators.api_changelog_gen` (9 functions, 2 classes)
|
|
235
|
+
📄 `code2docs.generators.api_reference_gen` (11 functions, 1 classes)
|
|
236
|
+
📄 `code2docs.generators.architecture_gen` (6 functions, 1 classes)
|
|
237
|
+
📄 `code2docs.generators.changelog_gen` (6 functions, 2 classes)
|
|
238
|
+
📄 `code2docs.generators.coverage_gen` (5 functions, 1 classes)
|
|
239
|
+
📄 `code2docs.generators.depgraph_gen` (8 functions, 1 classes)
|
|
240
|
+
📄 `code2docs.generators.examples_gen` (12 functions, 1 classes)
|
|
241
|
+
📄 `code2docs.generators.mkdocs_gen` (4 functions, 1 classes)
|
|
242
|
+
📄 `code2docs.generators.module_docs_gen` (17 functions, 1 classes)
|
|
243
|
+
📄 `code2docs.generators.readme_gen` (14 functions, 1 classes)
|
|
244
|
+
📦 `code2docs.sync`
|
|
245
|
+
📄 `code2docs.sync.differ` (7 functions, 2 classes)
|
|
246
|
+
📄 `code2docs.sync.updater` (2 functions, 1 classes)
|
|
247
|
+
📄 `code2docs.sync.watcher` (1 functions)
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
<!-- code2docs:end -->
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
Content outside markers is preserved.
|
|
254
|
+
|
|
255
|
+
## Architecture
|
|
256
|
+
|
|
257
|
+
```
|
|
258
|
+
code2docs/
|
|
259
|
+
├── cli.py # CLI (click-based)
|
|
260
|
+
├── config.py # Configuration (code2docs.yaml)
|
|
261
|
+
├── analyzers/ # Adapters to code2llm + custom detectors
|
|
262
|
+
│ ├── project_scanner.py # Wrapper on code2llm.ProjectAnalyzer
|
|
263
|
+
│ ├── endpoint_detector.py # Flask/FastAPI/Django route extraction
|
|
264
|
+
│ ├── docstring_extractor.py
|
|
265
|
+
│ └── dependency_scanner.py
|
|
266
|
+
├── generators/ # Documentation generators
|
|
267
|
+
│ ├── readme_gen.py # README.md generator
|
|
268
|
+
│ ├── api_reference_gen.py # docs/api/ reference from signatures
|
|
269
|
+
│ ├── module_docs_gen.py # docs/modules/ per-module docs
|
|
270
|
+
│ ├── examples_gen.py # examples/ from signatures
|
|
271
|
+
│ ├── changelog_gen.py # CHANGELOG from git log
|
|
272
|
+
│ └── architecture_gen.py # Architecture + Mermaid diagrams
|
|
273
|
+
├── templates/ # Jinja2 templates
|
|
274
|
+
├── sync/ # Change detection & selective regeneration
|
|
275
|
+
│ ├── differ.py
|
|
276
|
+
│ ├── updater.py
|
|
277
|
+
│ └── watcher.py
|
|
278
|
+
└── formatters/ # Markdown, badges, TOC
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
## Requirements
|
|
282
|
+
|
|
283
|
+
- Python >= 3.9
|
|
284
|
+
- [code2llm](https://github.com/wronai/code2llm) >= 0.5.0
|
|
285
|
+
- Jinja2 >= 3.1
|
|
286
|
+
- Click >= 8.0
|
|
287
|
+
- PyYAML >= 6.0
|
|
288
|
+
|
|
289
|
+
## License
|
|
290
|
+
|
|
291
|
+
Apache License 2.0 - see [LICENSE](LICENSE) for details.
|
|
292
|
+
|
|
293
|
+
## Author
|
|
294
|
+
|
|
295
|
+
Created by **Tom Sapletta** - [tom@sapletta.com](mailto:tom@sapletta.com)
|
|
@@ -5,7 +5,7 @@ Uses code2llm's AnalysisResult to produce human-readable documentation:
|
|
|
5
5
|
README.md, API references, module docs, examples, and architecture diagrams.
|
|
6
6
|
"""
|
|
7
7
|
|
|
8
|
-
__version__ = "0.1.
|
|
8
|
+
__version__ = "0.1.6"
|
|
9
9
|
__author__ = "Tom Sapletta"
|
|
10
10
|
|
|
11
11
|
from .config import Code2DocsConfig
|
|
@@ -115,6 +115,10 @@ def _run_generate(project_path: str, config: Code2DocsConfig,
|
|
|
115
115
|
from .generators.module_docs_gen import ModuleDocsGenerator
|
|
116
116
|
from .generators.examples_gen import ExamplesGenerator
|
|
117
117
|
from .generators.architecture_gen import ArchitectureGenerator
|
|
118
|
+
from .generators.depgraph_gen import DepGraphGenerator
|
|
119
|
+
from .generators.coverage_gen import CoverageGenerator
|
|
120
|
+
from .generators.mkdocs_gen import MkDocsGenerator
|
|
121
|
+
from .generators.api_changelog_gen import ApiChangelogGenerator
|
|
118
122
|
|
|
119
123
|
project = Path(project_path).resolve()
|
|
120
124
|
click.echo(f"📖 code2docs: analyzing {project.name}...")
|
|
@@ -169,13 +173,40 @@ def _run_generate(project_path: str, config: Code2DocsConfig,
|
|
|
169
173
|
arch_gen = ArchitectureGenerator(config, result)
|
|
170
174
|
content = arch_gen.generate()
|
|
171
175
|
if not dry_run:
|
|
172
|
-
|
|
173
|
-
arch_path.write_text(content, encoding="utf-8")
|
|
176
|
+
(docs_dir / "architecture.md").write_text(content, encoding="utf-8")
|
|
174
177
|
click.echo(f" ✅ docs/architecture.md")
|
|
175
178
|
else:
|
|
176
179
|
click.echo(f" [dry-run] docs/architecture.md")
|
|
177
180
|
|
|
178
|
-
# Step 4:
|
|
181
|
+
# Step 4: Dependency graph
|
|
182
|
+
depgraph_gen = DepGraphGenerator(config, result)
|
|
183
|
+
content = depgraph_gen.generate()
|
|
184
|
+
if not dry_run:
|
|
185
|
+
(docs_dir / "dependency-graph.md").write_text(content, encoding="utf-8")
|
|
186
|
+
click.echo(f" ✅ docs/dependency-graph.md")
|
|
187
|
+
else:
|
|
188
|
+
click.echo(f" [dry-run] docs/dependency-graph.md")
|
|
189
|
+
|
|
190
|
+
# Step 5: Docstring coverage
|
|
191
|
+
cov_gen = CoverageGenerator(config, result)
|
|
192
|
+
content = cov_gen.generate()
|
|
193
|
+
if not dry_run:
|
|
194
|
+
(docs_dir / "coverage.md").write_text(content, encoding="utf-8")
|
|
195
|
+
click.echo(f" ✅ docs/coverage.md")
|
|
196
|
+
else:
|
|
197
|
+
click.echo(f" [dry-run] docs/coverage.md")
|
|
198
|
+
|
|
199
|
+
# Step 6: API changelog (diff with previous snapshot)
|
|
200
|
+
api_cl_gen = ApiChangelogGenerator(config, result)
|
|
201
|
+
content = api_cl_gen.generate(str(project))
|
|
202
|
+
if not dry_run:
|
|
203
|
+
(docs_dir / "api-changelog.md").write_text(content, encoding="utf-8")
|
|
204
|
+
api_cl_gen.save_snapshot(str(project))
|
|
205
|
+
click.echo(f" ✅ docs/api-changelog.md")
|
|
206
|
+
else:
|
|
207
|
+
click.echo(f" [dry-run] docs/api-changelog.md")
|
|
208
|
+
|
|
209
|
+
# Step 7: Generate examples/
|
|
179
210
|
if config.examples.auto_generate:
|
|
180
211
|
ex_gen = ExamplesGenerator(config, result)
|
|
181
212
|
files = ex_gen.generate_all()
|
|
@@ -186,6 +217,15 @@ def _run_generate(project_path: str, config: Code2DocsConfig,
|
|
|
186
217
|
else:
|
|
187
218
|
click.echo(f" [dry-run] examples/ ({len(files)} files)")
|
|
188
219
|
|
|
220
|
+
# Step 8: mkdocs.yml
|
|
221
|
+
mkdocs_gen = MkDocsGenerator(config, result)
|
|
222
|
+
content = mkdocs_gen.generate(str(docs_dir))
|
|
223
|
+
if not dry_run:
|
|
224
|
+
mkdocs_gen.write(str(project / "mkdocs.yml"), content)
|
|
225
|
+
click.echo(f" ✅ mkdocs.yml")
|
|
226
|
+
else:
|
|
227
|
+
click.echo(f" [dry-run] mkdocs.yml")
|
|
228
|
+
|
|
189
229
|
click.echo("📖 Done!")
|
|
190
230
|
|
|
191
231
|
|
|
@@ -6,6 +6,10 @@ from .module_docs_gen import ModuleDocsGenerator
|
|
|
6
6
|
from .examples_gen import ExamplesGenerator
|
|
7
7
|
from .architecture_gen import ArchitectureGenerator
|
|
8
8
|
from .changelog_gen import ChangelogGenerator
|
|
9
|
+
from .depgraph_gen import DepGraphGenerator
|
|
10
|
+
from .coverage_gen import CoverageGenerator
|
|
11
|
+
from .mkdocs_gen import MkDocsGenerator
|
|
12
|
+
from .api_changelog_gen import ApiChangelogGenerator
|
|
9
13
|
|
|
10
14
|
__all__ = [
|
|
11
15
|
"ReadmeGenerator",
|
|
@@ -14,6 +18,10 @@ __all__ = [
|
|
|
14
18
|
"ExamplesGenerator",
|
|
15
19
|
"ArchitectureGenerator",
|
|
16
20
|
"ChangelogGenerator",
|
|
21
|
+
"DepGraphGenerator",
|
|
22
|
+
"CoverageGenerator",
|
|
23
|
+
"MkDocsGenerator",
|
|
24
|
+
"ApiChangelogGenerator",
|
|
17
25
|
"generate_docs",
|
|
18
26
|
]
|
|
19
27
|
|
|
@@ -39,4 +47,7 @@ def generate_docs(project_path: str, config=None):
|
|
|
39
47
|
if config.docs.architecture:
|
|
40
48
|
docs["architecture"] = ArchitectureGenerator(config, result).generate()
|
|
41
49
|
|
|
50
|
+
docs["dependency_graph"] = DepGraphGenerator(config, result).generate()
|
|
51
|
+
docs["coverage"] = CoverageGenerator(config, result).generate()
|
|
52
|
+
|
|
42
53
|
return docs
|