Skip to content

Commit 8e740bf

Browse files
refactoring
1 parent f328294 commit 8e740bf

17 files changed

Lines changed: 1605 additions & 60 deletions

docs/README.md

Lines changed: 374 additions & 0 deletions
Large diffs are not rendered by default.

project/README.md

Lines changed: 117 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# code2llm - Generated Analysis Files
2+
3+
This directory contains the complete analysis of your project generated by `code2llm`. Each file serves a specific purpose for understanding, refactoring, and documenting your codebase.
4+
15
## 📁 Generated Files Overview
26

37
When you run `code2llm ./ -f all`, the following files are created:
@@ -16,10 +20,30 @@ When you run `code2llm ./ -f all`, the following files are created:
1620
| `prompt.txt` | **Text** | **📝 Ready-to-send prompt** - Lists all files with instructions | Attach to LLM conversation as context guide |
1721
| `context.md` | **Markdown** | **📖 LLM narrative** - Architecture summary | Paste into ChatGPT/Claude for code analysis |
1822

23+
### 📊 Visualizations
24+
25+
| File | Format | Purpose | Description |
26+
|------|--------|---------|-------------|
27+
| `flow.mmd` | **Mermaid** | **🔄 Control flow diagram** | Function call paths with complexity styling |
28+
| `calls.mmd` | **Mermaid** | **📞 Call graph** | Function dependencies (edges only) |
29+
| `compact_flow.mmd` | **Mermaid** | **📦 Module overview** | Aggregated module-level view |
30+
31+
## 🚀 Quick Start Commands
32+
33+
### Basic Analysis
34+
```bash
35+
# Quick health check (TOON format only)
36+
code2llm ./ -f toon
37+
38+
# Generate all formats (what created these files)
39+
code2llm ./ -f all
40+
1941
# LLM-ready context only
2042
code2llm ./ -f context
2143
```
2244

45+
### Performance Options
46+
```bash
2347
# Fast analysis for large projects
2448
code2llm ./ -f toon --strategy quick
2549

@@ -30,6 +54,8 @@ code2llm ./ -f all --max-memory 500
3054
code2llm ./ -f all --no-png
3155
```
3256

57+
### Refactoring Focus
58+
```bash
3359
# Get refactoring recommendations
3460
code2llm ./ -f evolution
3561

@@ -40,6 +66,20 @@ code2llm ./ -f toon --refactor --smell god_function
4066
code2llm ./ -f flow --data-flow
4167
```
4268

69+
## 📖 Understanding Each File
70+
71+
### `analysis.toon` - Health Diagnostics
72+
**Purpose**: Quick overview of code health issues
73+
**Key sections**:
74+
- **HEALTH**: Critical issues (🔴) and warnings (🟡)
75+
- **REFACTOR**: Prioritized refactoring actions
76+
- **COUPLING**: Module dependencies and potential cycles
77+
- **LAYERS**: Package complexity metrics
78+
- **FUNCTIONS**: High-complexity functions (CC ≥ 10)
79+
- **CLASSES**: Complex classes needing attention
80+
81+
**Example usage**:
82+
```bash
4383
# View health issues
4484
cat analysis.toon | head -30
4585

@@ -122,24 +162,60 @@ grep -E "^ .*[0-9]{3,}$" project.toon.yaml | sort -t',' -k2 -n -r | head -10
122162

123163
**Example usage**:
124164
```bash
165+
# View the prompt
166+
cat prompt.txt
167+
125168
# Copy to clipboard and paste into ChatGPT/Claude
126169
cat prompt.txt | pbcopy # macOS
127170
cat prompt.txt | xclip -sel clip # Linux
128171
```
129172

173+
### `context.md` - LLM Narrative
174+
**Purpose**: Ready-to-paste context for AI assistants
175+
**Key sections**:
176+
- **Overview**: Project statistics
177+
- **Architecture**: Module breakdown
178+
- **Entry Points**: Public interfaces
179+
- **Patterns**: Design patterns detected
180+
181+
**Example usage**:
182+
```bash
130183
# Copy to clipboard for LLM
131184
cat context.md | pbcopy # macOS
132185
cat context.md | xclip -sel clip # Linux
133186

187+
# Use with Claude/ChatGPT for code analysis
188+
```
189+
190+
### Visualization Files (`*.mmd`, `*.png`)
191+
**Purpose**: Visual understanding of code structure
192+
**Files**:
193+
- `flow.mmd` - Detailed control flow with complexity colors
194+
- `calls.mmd` - Simple call graph
195+
- `compact_flow.mmd` - High-level module view
196+
- `*.png` - Pre-rendered images
197+
198+
**Example usage**:
199+
```bash
134200
# View diagrams
135201
open flow.png # macOS
136202
xdg-open flow.png # Linux
137203

204+
# Edit in Mermaid Live Editor
205+
# Copy content of .mmd files to https://mermaid.live
206+
```
207+
208+
## 🔍 Common Analysis Patterns
209+
210+
### 1. Code Health Assessment
211+
```bash
138212
# Quick health check
139213
code2llm ./ -f toon
140214
cat analysis.toon | grep -E "(HEALTH|REFACTOR)"
141215
```
142216

217+
### 2. Refactoring Planning
218+
```bash
143219
# Get refactoring queue
144220
code2llm ./ -f evolution
145221
cat evolution.toon.yaml
@@ -148,17 +224,33 @@ cat evolution.toon.yaml
148224
code2llm ./ -f toon --refactor --smell god_function
149225
```
150226

227+
### 3. LLM Assistance
228+
```bash
151229
# Generate context for AI
152230
code2llm ./ -f context
153231
cat context.md
154232

233+
# Use with Claude: "Based on this context, help me refactor the god modules"
234+
```
235+
236+
### 4. Team Documentation
237+
```bash
155238
# Generate all docs for team
156239
code2llm ./ -f all -o ./docs/
157240

158241
# Create visual diagrams
159242
open docs/flow.png
160243
```
161244

245+
## 📊 Interpreting Metrics
246+
247+
### Complexity Metrics (CC)
248+
- **🔴 Critical (≥5.0)**: Immediate refactoring needed
249+
- **🟠 High (3.0-4.9)**: Consider refactoring
250+
- **🟡 Medium (1.5-2.9)**: Monitor complexity
251+
- **🟢 Low (0.1-1.4)**: Acceptable
252+
- **⚪ Basic (0.0)**: Simple functions
253+
162254
### Module Health
163255
- **GOD Module**: Too large (>500 lines, >20 methods)
164256
- **HUB**: High fan-out (calls many modules)
@@ -170,6 +262,11 @@ open docs/flow.png
170262
- **CONTRACT**: Clear input/output specification
171263
- **SIDE_EFFECT**: External state modification
172264

265+
## 🛠️ Integration Examples
266+
267+
### CI/CD Pipeline
268+
```bash
269+
#!/bin/bash
173270
# Analyze code quality in CI
174271
code2llm ./ -f toon -o ./analysis
175272
if grep -q "🔴 GOD" ./analysis/analysis.toon; then
@@ -178,6 +275,9 @@ if grep -q "🔴 GOD" ./analysis/analysis.toon; then
178275
fi
179276
```
180277

278+
### Pre-commit Hook
279+
```bash
280+
#!/bin/sh
181281
# .git/hooks/pre-commit
182282
code2llm ./ -f toon -o ./temp_analysis
183283
if grep -q "🔴" ./temp_analysis/analysis.toon; then
@@ -186,12 +286,26 @@ fi
186286
rm -rf ./temp_analysis
187287
```
188288

289+
### Documentation Generation
290+
```bash
189291
# Generate docs for README
190292
code2llm ./ -f context -o ./docs/
191293
echo "## Architecture" >> README.md
192294
cat docs/context.md >> README.md
193295
```
194296

297+
## 📚 Next Steps
298+
299+
1. **Review `analysis.toon`** - Identify critical issues
300+
2. **Check `evolution.toon.yaml`** - Plan refactoring priorities
301+
3. **Use `context.md`** - Get LLM assistance for complex changes
302+
4. **Reference visualizations** - Understand system architecture
303+
5. **Track progress** - Re-run analysis after changes
304+
305+
## 🔧 Advanced Usage
306+
307+
### Custom Analysis
308+
```bash
195309
# Deep analysis with all insights
196310
code2llm ./ -m hybrid -f all --max-depth 15 -v
197311

@@ -202,6 +316,8 @@ code2llm ./ -m static -f toon --strategy quick
202316
code2llm ./ -f toon,evolution --refactor
203317
```
204318

319+
### Output Customization
320+
```bash
205321
# Separate output directories
206322
code2llm ./ -f all -o ./analysis-$(date +%Y%m%d)
207323

@@ -215,7 +331,7 @@ code2llm ./ -f yaml --separate-orphans
215331
---
216332

217333
**Generated by**: `code2llm ./ -f all --readme`
218-
**Analysis Date**: 2026-04-13
334+
**Analysis Date**: 2026-04-19
219335
**Total Functions**: 351
220336
**Total Classes**: 60
221337
**Modules**: 54

project/analysis.toon.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# code2llm | 39f 5459L | python:38,shell:1 | 2026-04-13
1+
# code2llm | 39f 5459L | python:38,shell:1 | 2026-04-19
22
# CC̄=3.8 | critical:0/351 | dups:0 | cycles:1
33

44
HEALTH[0]: ok

project/calls.mmd

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,43 +4,43 @@ flowchart LR
44
end
55
subgraph code2docs__cli
66
code2docs__cli___run_sync["_run_sync"]
7-
code2docs__cli___run_watch["_run_watch"]
87
code2docs__cli___run_check["_run_check"]
9-
code2docs__cli__watch["watch"]
10-
code2docs__cli___run_diff["_run_diff"]
11-
code2docs__cli___load_config["_load_config"]
128
code2docs__cli__diff["diff"]
9+
code2docs__cli___run_watch["_run_watch"]
10+
code2docs__cli___load_config["_load_config"]
11+
code2docs__cli___run_diff["_run_diff"]
1312
code2docs__cli__sync["sync"]
1413
code2docs__cli__check["check"]
14+
code2docs__cli__watch["watch"]
1515
end
1616
subgraph code2docs__config
1717
code2docs__config__Code2DocsConfig__from_yaml["from_yaml"]
1818
end
1919
subgraph code2docs__formatters
20-
code2docs__formatters__badges___make_badge["_make_badge"]
21-
code2docs__formatters__badges__generate_badges["generate_badges"]
20+
code2docs__formatters__toc___slugify["_slugify"]
2221
code2docs__formatters__toc__extract_headings["extract_headings"]
22+
code2docs__formatters__badges___make_badge["_make_badge"]
2323
code2docs__formatters__toc__generate_toc["generate_toc"]
24-
code2docs__formatters__toc___slugify["_slugify"]
24+
code2docs__formatters__badges__generate_badges["generate_badges"]
2525
end
2626
subgraph code2docs__generators
27-
code2docs__generators__readme_gen__ReadmeGenerator___build_context["_build_context"]
28-
code2docs__generators__code2llm_gen__parse_gitignore["parse_gitignore"]
29-
code2docs__generators__contributing_gen__ContributingGenerator___get_style_lines["_get_style_lines"]
30-
code2docs__generators__code2llm_gen__Code2LlmGenerator___add_exclude_patterns["_add_exclude_patterns"]
31-
code2docs__generators__code2llm_gen___should_skip_line["_should_skip_line"]
32-
code2docs__generators__code2llm_gen___clean_pattern["_clean_pattern"]
27+
code2docs__generators__code2llm_gen___extract_patterns["_extract_patterns"]
3328
code2docs__generators__contributing_gen__ContributingGenerator___get_python_style_lines["_get_python_style_lines"]
34-
code2docs__generators__code2llm_gen___is_valid_pattern["_is_valid_pattern"]
3529
code2docs__generators__contributing_gen__ContributingGenerator___render_code_style["_render_code_style"]
30+
code2docs__generators__code2llm_gen__parse_gitignore["parse_gitignore"]
3631
code2docs__generators__contributing_gen__ContributingGenerator___get_jsts_style_lines["_get_jsts_style_lines"]
37-
code2docs__generators__code2llm_gen___extract_patterns["_extract_patterns"]
38-
code2docs__generators__code2llm_gen___process_line["_process_line"]
32+
code2docs__generators__code2llm_gen___should_skip_line["_should_skip_line"]
33+
code2docs__generators__code2llm_gen___is_valid_pattern["_is_valid_pattern"]
34+
code2docs__generators__code2llm_gen___clean_pattern["_clean_pattern"]
35+
code2docs__generators__readme_gen__ReadmeGenerator___build_context["_build_context"]
36+
code2docs__generators__contributing_gen__ContributingGenerator___get_style_lines["_get_style_lines"]
3937
code2docs__generators__readme_gen__generate_readme["generate_readme"]
38+
code2docs__generators__code2llm_gen___process_line["_process_line"]
39+
code2docs__generators__code2llm_gen__Code2LlmGenerator___add_exclude_patterns["_add_exclude_patterns"]
4040
end
4141
subgraph code2docs__llm_helper
42-
code2docs__llm_helper__LLMHelper__complete["complete"]
4342
code2docs__llm_helper___get_litellm["_get_litellm"]
43+
code2docs__llm_helper__LLMHelper__complete["complete"]
4444
end
4545
subgraph code2docs__sync
4646
code2docs__sync__watcher__start_watcher["start_watcher"]
@@ -49,11 +49,11 @@ flowchart LR
4949
examples__02_configuration__load_config_from_yaml["load_config_from_yaml"]
5050
end
5151
subgraph examples__03_programmatic_api
52-
examples__03_programmatic_api__generate_readme_simple["generate_readme_simple"]
5352
examples__03_programmatic_api__custom_documentation_pipeline["custom_documentation_pipeline"]
5453
examples__03_programmatic_api__inspect_project_structure["inspect_project_structure"]
55-
examples__03_programmatic_api__generate_full_documentation["generate_full_documentation"]
5654
examples__03_programmatic_api__generate_docs_if_needed["generate_docs_if_needed"]
55+
examples__03_programmatic_api__generate_readme_simple["generate_readme_simple"]
56+
examples__03_programmatic_api__generate_full_documentation["generate_full_documentation"]
5757
end
5858
subgraph examples__04_sync_and_watch
5959
examples__04_sync_and_watch__watch_and_auto_regenerate["watch_and_auto_regenerate"]
@@ -62,15 +62,15 @@ flowchart LR
6262
examples__05_custom_generators__generate_custom_report["generate_custom_report"]
6363
end
6464
subgraph examples__06_formatters
65-
examples__06_formatters__build_custom_readme["build_custom_readme"]
6665
examples__06_formatters__badge_examples["badge_examples"]
6766
examples__06_formatters__toc_examples["toc_examples"]
67+
examples__06_formatters__build_custom_readme["build_custom_readme"]
6868
end
6969
subgraph examples__07_web_frameworks
7070
examples__07_web_frameworks__document_web_project["document_web_project"]
7171
examples__07_web_frameworks__generate_api_docs_from_endpoints["generate_api_docs_from_endpoin"]
72-
examples__07_web_frameworks__detect_flask_endpoints["detect_flask_endpoints"]
7372
examples__07_web_frameworks__detect_fastapi_endpoints["detect_fastapi_endpoints"]
73+
examples__07_web_frameworks__detect_flask_endpoints["detect_flask_endpoints"]
7474
end
7575
code2docs__formatters__badges__generate_badges --> code2docs__formatters__badges___make_badge
7676
code2docs__formatters__toc__generate_toc --> code2docs__formatters__toc__extract_headings

project/calls.png

-22.6 KB
Loading

0 commit comments

Comments
 (0)