code2docs 3.0.29__py3-none-any.whl → 3.0.30__py3-none-any.whl
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/__init__.py +1 -1
- code2docs/analyzers/__init__.py +10 -0
- code2docs/analyzers/dependency_scanner.py +26 -1
- code2docs/analyzers/markdown_validator.py +194 -0
- code2docs/config.py +1 -1
- code2docs/formatters/badges.py +20 -0
- code2docs/generators/readme_gen.py +3 -1
- code2docs/templates/readme.md.j2 +98 -2
- {code2docs-3.0.29.dist-info → code2docs-3.0.30.dist-info}/METADATA +8 -8
- {code2docs-3.0.29.dist-info → code2docs-3.0.30.dist-info}/RECORD +14 -13
- {code2docs-3.0.29.dist-info → code2docs-3.0.30.dist-info}/WHEEL +0 -0
- {code2docs-3.0.29.dist-info → code2docs-3.0.30.dist-info}/entry_points.txt +0 -0
- {code2docs-3.0.29.dist-info → code2docs-3.0.30.dist-info}/licenses/LICENSE +0 -0
- {code2docs-3.0.29.dist-info → code2docs-3.0.30.dist-info}/top_level.txt +0 -0
code2docs/__init__.py
CHANGED
|
@@ -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__ = '3.0.
|
|
8
|
+
__version__ = '3.0.30'
|
|
9
9
|
__author__ = 'Tom Sapletta'
|
|
10
10
|
__all__ = ['Code2DocsConfig', 'generate_readme', 'generate_docs', 'analyze_and_document']
|
|
11
11
|
|
code2docs/analyzers/__init__.py
CHANGED
|
@@ -4,10 +4,20 @@ from .project_scanner import ProjectScanner
|
|
|
4
4
|
from .endpoint_detector import EndpointDetector
|
|
5
5
|
from .docstring_extractor import DocstringExtractor
|
|
6
6
|
from .dependency_scanner import DependencyScanner
|
|
7
|
+
from .markdown_validator import (
|
|
8
|
+
MarkdownIssue,
|
|
9
|
+
ValidationReport,
|
|
10
|
+
validate_markdown_file,
|
|
11
|
+
validate_markdown_tree,
|
|
12
|
+
)
|
|
7
13
|
|
|
8
14
|
__all__ = [
|
|
9
15
|
"ProjectScanner",
|
|
10
16
|
"EndpointDetector",
|
|
11
17
|
"DocstringExtractor",
|
|
12
18
|
"DependencyScanner",
|
|
19
|
+
"MarkdownIssue",
|
|
20
|
+
"ValidationReport",
|
|
21
|
+
"validate_markdown_file",
|
|
22
|
+
"validate_markdown_tree",
|
|
13
23
|
]
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"""Scan project dependencies from requirements.txt, pyproject.toml, setup.py, package.json, Cargo.toml, go.mod."""
|
|
1
|
+
"""Scan project dependencies from requirements.txt, pyproject.toml, setup.py, package.json, composer.json, Cargo.toml, go.mod."""
|
|
2
2
|
import re
|
|
3
3
|
from dataclasses import dataclass, field
|
|
4
4
|
from pathlib import Path
|
|
@@ -50,6 +50,11 @@ class DependencyScanner:
|
|
|
50
50
|
if tsconfig.exists():
|
|
51
51
|
deps.language = 'typescript'
|
|
52
52
|
return deps
|
|
53
|
+
composer_json = project / 'composer.json'
|
|
54
|
+
if composer_json.exists():
|
|
55
|
+
deps = self._parse_composer_json(composer_json)
|
|
56
|
+
deps.source_file = 'composer.json'
|
|
57
|
+
return deps
|
|
53
58
|
cargo_toml = project / 'Cargo.toml'
|
|
54
59
|
if cargo_toml.exists():
|
|
55
60
|
deps = self._parse_cargo_toml(cargo_toml)
|
|
@@ -171,6 +176,26 @@ class DependencyScanner:
|
|
|
171
176
|
deps.keywords = data.get('keywords', [])
|
|
172
177
|
return deps
|
|
173
178
|
|
|
179
|
+
def _parse_composer_json(self, path: Path) -> ProjectDependencies:
|
|
180
|
+
"""Parse composer.json for PHP dependencies."""
|
|
181
|
+
import json
|
|
182
|
+
deps = ProjectDependencies(language='php')
|
|
183
|
+
try:
|
|
184
|
+
data = json.loads(path.read_text(encoding='utf-8'))
|
|
185
|
+
except (json.JSONDecodeError, OSError):
|
|
186
|
+
return deps
|
|
187
|
+
deps.version = data.get('version', '')
|
|
188
|
+
deps.keywords = data.get('keywords', []) or []
|
|
189
|
+
for dep_name, ver in (data.get('require', {}) or {}).items():
|
|
190
|
+
if dep_name.lower() == 'php':
|
|
191
|
+
deps.runtime_version = ver
|
|
192
|
+
continue
|
|
193
|
+
deps.dependencies.append(DependencyInfo(name=dep_name, version_spec=ver))
|
|
194
|
+
for dep_name, ver in (data.get('require-dev', {}) or {}).items():
|
|
195
|
+
deps.dev_dependencies.append(DependencyInfo(name=dep_name, version_spec=ver, group='dev'))
|
|
196
|
+
deps.install_command = 'composer install'
|
|
197
|
+
return deps
|
|
198
|
+
|
|
174
199
|
def _parse_cargo_toml(self, path: Path) -> ProjectDependencies:
|
|
175
200
|
"""Parse Cargo.toml for Rust dependencies."""
|
|
176
201
|
deps = ProjectDependencies(language='rust')
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
"""Validate generated markdown: checks local links/images, table shape, duplicate headings."""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
import re
|
|
5
|
+
from dataclasses import dataclass, field
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
from typing import Iterable, List, Optional
|
|
8
|
+
from urllib.parse import urlparse
|
|
9
|
+
|
|
10
|
+
_LINK_RE = re.compile(r'!?\[([^\]]*)\]\(([^)\s]+)(?:\s+"[^"]*")?\)')
|
|
11
|
+
_HEADING_RE = re.compile(r'^(#{1,6})\s+(.+?)\s*#*\s*$')
|
|
12
|
+
_FENCE_RE = re.compile(r'^(```|~~~)')
|
|
13
|
+
_TABLE_SEP_RE = re.compile(r'^\s*\|?\s*:?-{3,}:?\s*(\|\s*:?-{3,}:?\s*)+\|?\s*$')
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@dataclass
|
|
17
|
+
class MarkdownIssue:
|
|
18
|
+
"""A single validation issue in a markdown file."""
|
|
19
|
+
file: str
|
|
20
|
+
line: int
|
|
21
|
+
kind: str
|
|
22
|
+
message: str
|
|
23
|
+
|
|
24
|
+
def __str__(self) -> str:
|
|
25
|
+
return f'{self.file}:{self.line} [{self.kind}] {self.message}'
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
@dataclass
|
|
29
|
+
class ValidationReport:
|
|
30
|
+
"""Aggregate result of markdown validation."""
|
|
31
|
+
issues: List[MarkdownIssue] = field(default_factory=list)
|
|
32
|
+
files_checked: int = 0
|
|
33
|
+
|
|
34
|
+
@property
|
|
35
|
+
def ok(self) -> bool:
|
|
36
|
+
return not self.issues
|
|
37
|
+
|
|
38
|
+
def by_kind(self, kind: str) -> List[MarkdownIssue]:
|
|
39
|
+
return [i for i in self.issues if i.kind == kind]
|
|
40
|
+
|
|
41
|
+
def summary(self) -> str:
|
|
42
|
+
if self.ok:
|
|
43
|
+
return f'✅ {self.files_checked} file(s) checked, no issues'
|
|
44
|
+
kinds: dict = {}
|
|
45
|
+
for issue in self.issues:
|
|
46
|
+
kinds[issue.kind] = kinds.get(issue.kind, 0) + 1
|
|
47
|
+
parts = ', '.join(f'{k}={v}' for k, v in sorted(kinds.items()))
|
|
48
|
+
return f'❌ {len(self.issues)} issue(s) across {self.files_checked} file(s): {parts}'
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def validate_markdown_file(md_path: Path, project_root: Optional[Path] = None) -> List[MarkdownIssue]:
|
|
52
|
+
"""Validate a single markdown file.
|
|
53
|
+
|
|
54
|
+
Checks:
|
|
55
|
+
- Local links/images resolve to existing files (skips URLs and in-page anchors).
|
|
56
|
+
- Tables have consistent column count.
|
|
57
|
+
- Duplicate headings at the same level are flagged.
|
|
58
|
+
"""
|
|
59
|
+
md_path = Path(md_path)
|
|
60
|
+
if not md_path.exists():
|
|
61
|
+
return [MarkdownIssue(str(md_path), 0, 'missing', 'file does not exist')]
|
|
62
|
+
root = Path(project_root) if project_root else md_path.parent
|
|
63
|
+
try:
|
|
64
|
+
lines = md_path.read_text(encoding='utf-8').splitlines()
|
|
65
|
+
except OSError as exc:
|
|
66
|
+
return [MarkdownIssue(str(md_path), 0, 'read_error', str(exc))]
|
|
67
|
+
issues: List[MarkdownIssue] = []
|
|
68
|
+
issues.extend(_check_links(md_path, root, lines))
|
|
69
|
+
issues.extend(_check_tables(md_path, lines))
|
|
70
|
+
issues.extend(_check_headings(md_path, lines))
|
|
71
|
+
return issues
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def validate_markdown_tree(root: Path, patterns: Iterable[str] = ('*.md',),
|
|
75
|
+
ignore: Iterable[str] = ('node_modules', 'venv', '.venv',
|
|
76
|
+
'vendor', '.git', '__pycache__')) -> ValidationReport:
|
|
77
|
+
"""Validate every markdown file under ``root`` matching ``patterns``."""
|
|
78
|
+
root = Path(root)
|
|
79
|
+
ignore_set = set(ignore)
|
|
80
|
+
report = ValidationReport()
|
|
81
|
+
seen: set = set()
|
|
82
|
+
for pattern in patterns:
|
|
83
|
+
for md_file in root.rglob(pattern):
|
|
84
|
+
if any(part in ignore_set for part in md_file.parts):
|
|
85
|
+
continue
|
|
86
|
+
if md_file in seen:
|
|
87
|
+
continue
|
|
88
|
+
seen.add(md_file)
|
|
89
|
+
report.files_checked += 1
|
|
90
|
+
report.issues.extend(validate_markdown_file(md_file, project_root=root))
|
|
91
|
+
return report
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def _strip_code_fences(lines: List[str]) -> List[bool]:
|
|
95
|
+
"""Return a per-line boolean: True if the line is inside a fenced code block."""
|
|
96
|
+
inside = False
|
|
97
|
+
mask: List[bool] = []
|
|
98
|
+
for line in lines:
|
|
99
|
+
if _FENCE_RE.match(line.strip()):
|
|
100
|
+
mask.append(True)
|
|
101
|
+
inside = not inside
|
|
102
|
+
continue
|
|
103
|
+
mask.append(inside)
|
|
104
|
+
return mask
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def _check_links(md_path: Path, root: Path, lines: List[str]) -> List[MarkdownIssue]:
|
|
108
|
+
issues: List[MarkdownIssue] = []
|
|
109
|
+
in_code = _strip_code_fences(lines)
|
|
110
|
+
for lineno, line in enumerate(lines, 1):
|
|
111
|
+
if in_code[lineno - 1]:
|
|
112
|
+
continue
|
|
113
|
+
for match in _LINK_RE.finditer(line):
|
|
114
|
+
target = match.group(2).strip()
|
|
115
|
+
if not target or target.startswith('#'):
|
|
116
|
+
continue
|
|
117
|
+
parsed = urlparse(target)
|
|
118
|
+
if parsed.scheme in ('http', 'https', 'mailto', 'ftp', 'tel', 'data'):
|
|
119
|
+
continue
|
|
120
|
+
if parsed.scheme and parsed.scheme not in ('file',):
|
|
121
|
+
continue
|
|
122
|
+
rel = parsed.path
|
|
123
|
+
if not rel:
|
|
124
|
+
continue
|
|
125
|
+
if rel.startswith('/'):
|
|
126
|
+
resolved = root / rel.lstrip('/')
|
|
127
|
+
else:
|
|
128
|
+
resolved = (md_path.parent / rel).resolve()
|
|
129
|
+
if not resolved.exists():
|
|
130
|
+
issues.append(MarkdownIssue(
|
|
131
|
+
str(md_path), lineno, 'broken_link',
|
|
132
|
+
f'link target not found: {target}'))
|
|
133
|
+
return issues
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
def _check_tables(md_path: Path, lines: List[str]) -> List[MarkdownIssue]:
|
|
137
|
+
issues: List[MarkdownIssue] = []
|
|
138
|
+
in_code = _strip_code_fences(lines)
|
|
139
|
+
i = 0
|
|
140
|
+
while i < len(lines):
|
|
141
|
+
if in_code[i]:
|
|
142
|
+
i += 1
|
|
143
|
+
continue
|
|
144
|
+
line = lines[i]
|
|
145
|
+
if '|' in line and i + 1 < len(lines) and _TABLE_SEP_RE.match(lines[i + 1]):
|
|
146
|
+
header_cols = _count_cells(line)
|
|
147
|
+
sep_cols = _count_cells(lines[i + 1])
|
|
148
|
+
if header_cols != sep_cols:
|
|
149
|
+
issues.append(MarkdownIssue(
|
|
150
|
+
str(md_path), i + 2, 'table_shape',
|
|
151
|
+
f'separator has {sep_cols} cells, header has {header_cols}'))
|
|
152
|
+
j = i + 2
|
|
153
|
+
while j < len(lines) and not in_code[j] and lines[j].strip() and '|' in lines[j]:
|
|
154
|
+
cells = _count_cells(lines[j])
|
|
155
|
+
if cells != header_cols:
|
|
156
|
+
issues.append(MarkdownIssue(
|
|
157
|
+
str(md_path), j + 1, 'table_shape',
|
|
158
|
+
f'row has {cells} cells, expected {header_cols}'))
|
|
159
|
+
j += 1
|
|
160
|
+
i = j
|
|
161
|
+
else:
|
|
162
|
+
i += 1
|
|
163
|
+
return issues
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
def _count_cells(row: str) -> int:
|
|
167
|
+
stripped = row.strip()
|
|
168
|
+
if stripped.startswith('|'):
|
|
169
|
+
stripped = stripped[1:]
|
|
170
|
+
if stripped.endswith('|'):
|
|
171
|
+
stripped = stripped[:-1]
|
|
172
|
+
return len(stripped.split('|'))
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
def _check_headings(md_path: Path, lines: List[str]) -> List[MarkdownIssue]:
|
|
176
|
+
issues: List[MarkdownIssue] = []
|
|
177
|
+
in_code = _strip_code_fences(lines)
|
|
178
|
+
seen: dict = {}
|
|
179
|
+
for lineno, line in enumerate(lines, 1):
|
|
180
|
+
if in_code[lineno - 1]:
|
|
181
|
+
continue
|
|
182
|
+
match = _HEADING_RE.match(line)
|
|
183
|
+
if not match:
|
|
184
|
+
continue
|
|
185
|
+
level = len(match.group(1))
|
|
186
|
+
title = match.group(2).strip().lower()
|
|
187
|
+
key = (level, title)
|
|
188
|
+
if key in seen:
|
|
189
|
+
issues.append(MarkdownIssue(
|
|
190
|
+
str(md_path), lineno, 'duplicate_heading',
|
|
191
|
+
f'H{level} "{match.group(2).strip()}" already at line {seen[key]}'))
|
|
192
|
+
else:
|
|
193
|
+
seen[key] = lineno
|
|
194
|
+
return issues
|
code2docs/config.py
CHANGED
|
@@ -14,7 +14,7 @@ except ImportError:
|
|
|
14
14
|
@dataclass
|
|
15
15
|
class ReadmeConfig:
|
|
16
16
|
"""Configuration for README generation."""
|
|
17
|
-
sections: List[str] = field(default_factory=lambda: ['overview', 'install', 'quickstart', '
|
|
17
|
+
sections: List[str] = field(default_factory=lambda: ['overview', 'install', 'quickstart', 'architecture', 'api', 'structure', 'requirements', 'endpoints', 'contributing', 'docs_nav'])
|
|
18
18
|
badges: List[str] = field(default_factory=lambda: ['version', 'python', 'coverage', 'complexity'])
|
|
19
19
|
sync_markers: bool = True
|
|
20
20
|
|
code2docs/formatters/badges.py
CHANGED
|
@@ -27,6 +27,9 @@ def _make_badge(badge_type: str, project_name: str,
|
|
|
27
27
|
return f""
|
|
28
28
|
|
|
29
29
|
elif badge_type == "python":
|
|
30
|
+
lang = getattr(deps, "language", "python") if deps else "python"
|
|
31
|
+
if lang and lang != "python":
|
|
32
|
+
return _runtime_badge(lang, deps)
|
|
30
33
|
py_version = ""
|
|
31
34
|
if deps and hasattr(deps, "python_version"):
|
|
32
35
|
py_version = deps.python_version
|
|
@@ -50,3 +53,20 @@ def _make_badge(badge_type: str, project_name: str,
|
|
|
50
53
|
return f""
|
|
51
54
|
|
|
52
55
|
return None
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
_RUNTIME_LABELS = {
|
|
59
|
+
"php": ("php", "777BB4"),
|
|
60
|
+
"javascript": ("node", "339933"),
|
|
61
|
+
"typescript": ("typescript", "3178C6"),
|
|
62
|
+
"rust": ("rust", "B7410E"),
|
|
63
|
+
"go": ("go", "00ADD8"),
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def _runtime_badge(lang: str, deps) -> Optional[str]:
|
|
68
|
+
"""Generate a runtime badge for non-Python languages."""
|
|
69
|
+
label, color = _RUNTIME_LABELS.get(lang, (lang, "blue"))
|
|
70
|
+
version = getattr(deps, "runtime_version", "") if deps else ""
|
|
71
|
+
version = version or "any"
|
|
72
|
+
return f"}-{quote(version)}-{color})"
|
|
@@ -57,7 +57,9 @@ class ReadmeGenerator:
|
|
|
57
57
|
project_description = self._generate_description(project_name, entry_points)
|
|
58
58
|
metadata = self._extract_project_metadata()
|
|
59
59
|
extras = self._extract_extras()
|
|
60
|
-
|
|
60
|
+
lang = getattr(deps, 'language', 'python') or 'python'
|
|
61
|
+
docs_nav_items, generated_files = self._collect_existing_docs()
|
|
62
|
+
return {'docs_nav_items': docs_nav_items, 'generated_files': generated_files, 'project_name': project_name, 'project_path': self.result.project_path, 'project_description': project_description, 'badges': generate_badges(project_name, self.config.readme.badges, stats, deps), 'stats': stats, 'avg_complexity': avg_complexity, 'dependencies': deps, 'language': lang, 'endpoints': endpoints, 'public_functions': public_functions, 'public_classes': public_classes, 'entry_points': entry_points, 'module_tree': module_tree, 'modules': self.result.modules, 'sync_markers': self.config.readme.sync_markers, 'author': metadata.get('author', ''), 'license': metadata.get('license', ''), 'license_file': metadata.get('license_file', ''), 'contributors': metadata.get('contributors', []), 'repo_url': self.config.repo_url, 'version': metadata.get('version', '0.1.0'), 'extras': extras}
|
|
61
63
|
|
|
62
64
|
def _calc_avg_complexity(self) -> float:
|
|
63
65
|
"""Calculate average cyclomatic complexity."""
|
code2docs/templates/readme.md.j2
CHANGED
|
@@ -23,6 +23,50 @@
|
|
|
23
23
|
{% if "install" in sections %}
|
|
24
24
|
## Installation
|
|
25
25
|
|
|
26
|
+
{% if language == 'php' %}
|
|
27
|
+
### Requirements
|
|
28
|
+
|
|
29
|
+
{% if dependencies and dependencies.runtime_version %}- PHP {{ dependencies.runtime_version }}
|
|
30
|
+
{% else %}- PHP 8.0+
|
|
31
|
+
{% endif %}- [Composer](https://getcomposer.org/)
|
|
32
|
+
|
|
33
|
+
### From Source
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
git clone {{ repo_url or '<repository-url>' }}
|
|
37
|
+
cd {{ project_name }}
|
|
38
|
+
composer install
|
|
39
|
+
```
|
|
40
|
+
{% elif language in ('javascript', 'typescript') %}
|
|
41
|
+
### Requirements
|
|
42
|
+
|
|
43
|
+
{% if dependencies and dependencies.runtime_version %}- Node.js {{ dependencies.runtime_version }}
|
|
44
|
+
{% else %}- Node.js 18+
|
|
45
|
+
{% endif %}
|
|
46
|
+
### From Source
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
git clone {{ repo_url or '<repository-url>' }}
|
|
50
|
+
cd {{ project_name }}
|
|
51
|
+
{{ dependencies.install_command if dependencies and dependencies.install_command else 'npm install' }}
|
|
52
|
+
```
|
|
53
|
+
{% elif language == 'rust' %}
|
|
54
|
+
### From Source
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
git clone {{ repo_url or '<repository-url>' }}
|
|
58
|
+
cd {{ project_name }}
|
|
59
|
+
cargo build --release
|
|
60
|
+
```
|
|
61
|
+
{% elif language == 'go' %}
|
|
62
|
+
### From Source
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
git clone {{ repo_url or '<repository-url>' }}
|
|
66
|
+
cd {{ project_name }}
|
|
67
|
+
go build ./...
|
|
68
|
+
```
|
|
69
|
+
{% else %}
|
|
26
70
|
### From PyPI
|
|
27
71
|
|
|
28
72
|
```bash
|
|
@@ -46,10 +90,37 @@ pip install -e .
|
|
|
46
90
|
```
|
|
47
91
|
{% endif %}
|
|
48
92
|
{% endif %}
|
|
93
|
+
{% endif %}
|
|
49
94
|
|
|
50
95
|
{% if "quickstart" in sections %}
|
|
51
96
|
## Quick Start
|
|
52
97
|
|
|
98
|
+
{% if language == 'php' %}
|
|
99
|
+
Serve the project with your preferred PHP runtime (built-in server shown for local development):
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
php -S localhost:8000
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Or with Docker Compose if a `docker-compose.yml` is provided:
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
docker compose up
|
|
109
|
+
```
|
|
110
|
+
{% elif language in ('javascript', 'typescript') %}
|
|
111
|
+
```bash
|
|
112
|
+
{% if dependencies and dependencies.install_command %}{{ dependencies.install_command }}
|
|
113
|
+
{% endif %}npm start
|
|
114
|
+
```
|
|
115
|
+
{% elif language == 'rust' %}
|
|
116
|
+
```bash
|
|
117
|
+
cargo run
|
|
118
|
+
```
|
|
119
|
+
{% elif language == 'go' %}
|
|
120
|
+
```bash
|
|
121
|
+
go run .
|
|
122
|
+
```
|
|
123
|
+
{% else %}
|
|
53
124
|
### CLI Usage
|
|
54
125
|
|
|
55
126
|
```bash
|
|
@@ -82,6 +153,7 @@ config = Code2DocsConfig(project_name="mylib", verbose=True)
|
|
|
82
153
|
docs = generate_docs("./my-project", config=config)
|
|
83
154
|
```
|
|
84
155
|
{% endif %}
|
|
156
|
+
{% endif %}
|
|
85
157
|
|
|
86
158
|
{% if "generated_output" in sections %}
|
|
87
159
|
## Generated Output
|
|
@@ -171,8 +243,12 @@ Content outside the markers is preserved when regenerating. Enable this with `sy
|
|
|
171
243
|
|
|
172
244
|
```
|
|
173
245
|
{{ project_name }}/
|
|
174
|
-
{% for mod_name, mod in modules.items()|list
|
|
175
|
-
{%
|
|
246
|
+
{% for mod_name, mod in modules.items()|list -%}
|
|
247
|
+
{% if not mod_name.startswith('_') -%}
|
|
248
|
+
{% set parts = mod_name.split('.') -%}
|
|
249
|
+
{{ ' ' * (parts|length - 1) }}├── {{ parts[-1] }}{% if mod.is_package %}/{% endif %}{{ "\n" -}}
|
|
250
|
+
{% endif -%}
|
|
251
|
+
{% endfor -%}
|
|
176
252
|
```
|
|
177
253
|
{% endif %}
|
|
178
254
|
|
|
@@ -249,11 +325,31 @@ We welcome contributions! Please see [CONTRIBUTING.md](./CONTRIBUTING.md) for gu
|
|
|
249
325
|
git clone {{ repo_url or '<repository-url>' }}
|
|
250
326
|
cd {{ project_name }}
|
|
251
327
|
|
|
328
|
+
{% if language == 'php' %}
|
|
329
|
+
# Install dependencies
|
|
330
|
+
composer install
|
|
331
|
+
|
|
332
|
+
# Run tests
|
|
333
|
+
vendor/bin/phpunit
|
|
334
|
+
{% elif language in ('javascript', 'typescript') %}
|
|
335
|
+
# Install dependencies
|
|
336
|
+
{{ dependencies.install_command if dependencies and dependencies.install_command else 'npm install' }}
|
|
337
|
+
|
|
338
|
+
# Run tests
|
|
339
|
+
npm test
|
|
340
|
+
{% elif language == 'rust' %}
|
|
341
|
+
# Run tests
|
|
342
|
+
cargo test
|
|
343
|
+
{% elif language == 'go' %}
|
|
344
|
+
# Run tests
|
|
345
|
+
go test ./...
|
|
346
|
+
{% else %}
|
|
252
347
|
# Install in development mode
|
|
253
348
|
pip install -e ".[dev]"
|
|
254
349
|
|
|
255
350
|
# Run tests
|
|
256
351
|
pytest
|
|
352
|
+
{% endif %}
|
|
257
353
|
```
|
|
258
354
|
{% endif %}
|
|
259
355
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: code2docs
|
|
3
|
-
Version: 3.0.
|
|
3
|
+
Version: 3.0.30
|
|
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
|
|
@@ -53,17 +53,17 @@ Dynamic: license-file
|
|
|
53
53
|
|
|
54
54
|
## AI Cost Tracking
|
|
55
55
|
|
|
56
|
-
     
|
|
57
|
+
  
|
|
58
58
|
|
|
59
|
-
- 🤖 **LLM usage:** $7.5000 (
|
|
60
|
-
- 👤 **Human dev:** ~$
|
|
59
|
+
- 🤖 **LLM usage:** $7.5000 (70 commits)
|
|
60
|
+
- 👤 **Human dev:** ~$2434 (24.3h @ $100/h, 30min dedup)
|
|
61
61
|
|
|
62
|
-
Generated on 2026-04-
|
|
62
|
+
Generated on 2026-04-20 using [openrouter/qwen/qwen3-coder-next](https://openrouter.ai/qwen/qwen3-coder-next)
|
|
63
63
|
|
|
64
64
|
---
|
|
65
65
|
|
|
66
|
-
  
|
|
67
67
|
|
|
68
68
|
> Auto-generate and sync project documentation from source code analysis.
|
|
69
69
|
|
|
@@ -200,7 +200,7 @@ code2docs can update only specific sections of an existing README using markers:
|
|
|
200
200
|
```markdown
|
|
201
201
|
<!-- code2docs:start --># code2docs
|
|
202
202
|
|
|
203
|
-
   
|
|
204
204
|
> **276** functions | **57** classes | **51** files | CC̄ = 3.8
|
|
205
205
|
|
|
206
206
|
> Auto-generated project documentation from source code analysis.
|
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
code2docs/__init__.py,sha256=
|
|
1
|
+
code2docs/__init__.py,sha256=_pBUiOybWxKLxk_HHp5_JjIbjpAo-faaic7ZB0T3Fys,901
|
|
2
2
|
code2docs/__main__.py,sha256=dGGkQIZVFDZXEXa9PWew7cBh7hBAYDWfJ9LeezMf2UI,116
|
|
3
3
|
code2docs/base.py,sha256=tQT0I9iAxpxtCNHFZL8kYdgCD-96ywOvDKD2Iiksgj4,1319
|
|
4
4
|
code2docs/cli.py,sha256=k1mhqb3ykeqpnSfolsZSn3lVPkR8wde9DQdKlON1w0o,11283
|
|
5
|
-
code2docs/config.py,sha256=
|
|
5
|
+
code2docs/config.py,sha256=WH101glXT9chJH016g1z7uZy8l8dbNbhnN_rOU2BSsE,8825
|
|
6
6
|
code2docs/llm_helper.py,sha256=2Q_pnOBeei9EVU9HL_dWmqUpdkSzYNlMfIr5OOQcLws,6155
|
|
7
7
|
code2docs/registry.py,sha256=aD3pdTAF2VeTMVddoQdt6QCB9b15FQywLE0W8Uca0xk,1256
|
|
8
|
-
code2docs/analyzers/__init__.py,sha256=
|
|
9
|
-
code2docs/analyzers/dependency_scanner.py,sha256=
|
|
8
|
+
code2docs/analyzers/__init__.py,sha256=4m_W6ch3mfNJVVk5CG5G4-kqA28KzPz_uvzYhznxj6Q,608
|
|
9
|
+
code2docs/analyzers/dependency_scanner.py,sha256=cnsoggrEVSJV9jZFCyIIyJuJyEYqG8V0lig8EKo0ymE,11924
|
|
10
10
|
code2docs/analyzers/docstring_extractor.py,sha256=gu2NqvnkFu8Mii1lxCZk1jBKNPkCVj09iiapaRrgX_Y,5060
|
|
11
11
|
code2docs/analyzers/endpoint_detector.py,sha256=IlRY6vEw-uUy4CTN3AOEkM6IcohcMy0iZDOoQJxrrno,3827
|
|
12
|
+
code2docs/analyzers/markdown_validator.py,sha256=TOkWcNzDdRkaLrCo2q-09YHj6iYj_JLBs8RH35q07UM,6974
|
|
12
13
|
code2docs/analyzers/project_scanner.py,sha256=Ru86nrT_SyMN8wYuQ2tu0lK1WM7Z4K9zUXOmpNNDJ6Q,1599
|
|
13
14
|
code2docs/examples/advanced_usage.py,sha256=sHyXrXV5p9t6B9OpZndPNrClBSSEzSmjlsvoMT7cp9k,2741
|
|
14
15
|
code2docs/examples/quickstart.py,sha256=VDJfpRtMFZOBZAGXLkJ65ELUncjF7YM0x2vIm3aZmrA,1301
|
|
15
16
|
code2docs/formatters/__init__.py,sha256=3-myGxFceSgOW3g1eQFUJO3tEDF03MbG-7WL1WEylk4,240
|
|
16
|
-
code2docs/formatters/badges.py,sha256=
|
|
17
|
+
code2docs/formatters/badges.py,sha256=wGBCKDu2bK3Lsiyus6b9ow1nHzgMlCPIagAdsmk8S1M,2461
|
|
17
18
|
code2docs/formatters/markdown.py,sha256=yfmicI9-T0WnyFoZRe4XrB2Wc847kNqK7q0VSeP8zVg,2278
|
|
18
19
|
code2docs/formatters/toc.py,sha256=EBynYUlgkk5W5_QqsRHWbIW2Cfpk3sJulk3FvURHK60,1770
|
|
19
20
|
code2docs/generators/__init__.py,sha256=U1p6nY6pLLTXF7wY2TgnQ017bXZf3vtJ2iTAWsk4ejA,1988
|
|
@@ -33,7 +34,7 @@ code2docs/generators/getting_started_gen.py,sha256=P--4A0Lmeo338zKjuD1D5BYxVJ5IG
|
|
|
33
34
|
code2docs/generators/mkdocs_gen.py,sha256=ciETCRUzb3V3kSGAslM5DStHJUQ1Ju-pTxC1Iv_duzo,3849
|
|
34
35
|
code2docs/generators/module_docs_gen.py,sha256=6FFH69AQlNxPlEMEEeX0ND366rb7URSP6geNlvf_Sjk,10090
|
|
35
36
|
code2docs/generators/org_readme_gen.py,sha256=Saf7iZbHwtXcqXAl1EYmufl6mZ4msc-SFsVWj1Zqptw,9411
|
|
36
|
-
code2docs/generators/readme_gen.py,sha256=
|
|
37
|
+
code2docs/generators/readme_gen.py,sha256=ymxdPvNZdWhxLwwtJdX-CDjfj25BxGPugiaZ0P9Sbio,17548
|
|
37
38
|
code2docs/sync/__init__.py,sha256=MOTJYvJXPZF-4PS47lv-6bOc9J2ZoQGoIchp3vIuwrU,162
|
|
38
39
|
code2docs/sync/differ.py,sha256=3dtu95BiiTXaz8tU63Ot6_W9DAHdFoKVd3OIiFz7Qiw,4160
|
|
39
40
|
code2docs/sync/updater.py,sha256=ZuRcVtoubxwPnuuTn8s05h1xLoSNwzaNlm_XKAJdf94,1971
|
|
@@ -43,10 +44,10 @@ code2docs/templates/architecture.md.j2,sha256=kx_lECcC9FGHTEnhgPNVGIijDFXu5xFcm4
|
|
|
43
44
|
code2docs/templates/example_usage.py.j2,sha256=G0mF7iLtisnsh-PfPTMLgVoNSDw6J-MqPndzMTtcuJk,225
|
|
44
45
|
code2docs/templates/index.md.j2,sha256=pj56gwiLuXxV64xVYfzmtboMLyFKF-Kty01Ps0t37xM,653
|
|
45
46
|
code2docs/templates/module_doc.md.j2,sha256=oMcaDSSCbyMSjQtnal7garYr4dDbTcRAQobsjrYVYGo,1876
|
|
46
|
-
code2docs/templates/readme.md.j2,sha256=
|
|
47
|
-
code2docs-3.0.
|
|
48
|
-
code2docs-3.0.
|
|
49
|
-
code2docs-3.0.
|
|
50
|
-
code2docs-3.0.
|
|
51
|
-
code2docs-3.0.
|
|
52
|
-
code2docs-3.0.
|
|
47
|
+
code2docs/templates/readme.md.j2,sha256=G_qgTt6aFv8ZnYZa7MSbBe4DB8RyXhHbVDR8OHFp-8k,10393
|
|
48
|
+
code2docs-3.0.30.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
49
|
+
code2docs-3.0.30.dist-info/METADATA,sha256=9OEo5U-MeCLCL5TKlotFBB6TnBsZjPVAxlEb8KnadPs,26843
|
|
50
|
+
code2docs-3.0.30.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
51
|
+
code2docs-3.0.30.dist-info/entry_points.txt,sha256=ATamjPNo2CbTaAUN3LfK8qrnY3EQE9gE7lMDgPYhLdQ,49
|
|
52
|
+
code2docs-3.0.30.dist-info/top_level.txt,sha256=L-O2M4M-NSiphgcKSfXFsC-t6PqziMl8Ef6tsNR2DaM,10
|
|
53
|
+
code2docs-3.0.30.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|