codedocent 0.1.0__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.
- codedocent-0.1.0/LICENSE +21 -0
- codedocent-0.1.0/PKG-INFO +16 -0
- codedocent-0.1.0/README.md +163 -0
- codedocent-0.1.0/codedocent/__init__.py +1 -0
- codedocent-0.1.0/codedocent/__main__.py +4 -0
- codedocent-0.1.0/codedocent/analyzer.py +620 -0
- codedocent-0.1.0/codedocent/cli.py +132 -0
- codedocent-0.1.0/codedocent/editor.py +85 -0
- codedocent-0.1.0/codedocent/parser.py +369 -0
- codedocent-0.1.0/codedocent/renderer.py +79 -0
- codedocent-0.1.0/codedocent/scanner.py +135 -0
- codedocent-0.1.0/codedocent/server.py +304 -0
- codedocent-0.1.0/codedocent/templates/base.html +538 -0
- codedocent-0.1.0/codedocent/templates/interactive.html +1032 -0
- codedocent-0.1.0/codedocent.egg-info/PKG-INFO +16 -0
- codedocent-0.1.0/codedocent.egg-info/SOURCES.txt +26 -0
- codedocent-0.1.0/codedocent.egg-info/dependency_links.txt +1 -0
- codedocent-0.1.0/codedocent.egg-info/entry_points.txt +2 -0
- codedocent-0.1.0/codedocent.egg-info/requires.txt +9 -0
- codedocent-0.1.0/codedocent.egg-info/top_level.txt +1 -0
- codedocent-0.1.0/pyproject.toml +27 -0
- codedocent-0.1.0/setup.cfg +4 -0
- codedocent-0.1.0/tests/test_analyzer.py +543 -0
- codedocent-0.1.0/tests/test_editor.py +113 -0
- codedocent-0.1.0/tests/test_parser.py +129 -0
- codedocent-0.1.0/tests/test_renderer.py +253 -0
- codedocent-0.1.0/tests/test_scanner.py +95 -0
- codedocent-0.1.0/tests/test_server.py +340 -0
codedocent-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Brandon
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: codedocent
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Code visualization for non-programmers
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
Requires-Python: >=3.10
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Requires-Dist: tree-sitter>=0.23
|
|
9
|
+
Requires-Dist: tree-sitter-language-pack>=0.13
|
|
10
|
+
Requires-Dist: radon>=6.0
|
|
11
|
+
Requires-Dist: pathspec>=0.11
|
|
12
|
+
Requires-Dist: jinja2>=3.1
|
|
13
|
+
Requires-Dist: ollama>=0.4
|
|
14
|
+
Provides-Extra: dev
|
|
15
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
16
|
+
Dynamic: license-file
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
# codedocent
|
|
2
|
+
|
|
3
|
+
**Code visualization for non-programmers.**
|
|
4
|
+
|
|
5
|
+
A docent is a guide who explains things to people who aren't experts. Codedocent does that for code.
|
|
6
|
+
|
|
7
|
+
> Google Translate for code → human understanding.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## What it does
|
|
12
|
+
|
|
13
|
+
Codedocent takes any codebase and turns it into a visual, navigable map that anyone can read — no programming knowledge required.
|
|
14
|
+
|
|
15
|
+
Every piece of code becomes a **block** that shows:
|
|
16
|
+
- A **plain English explanation** of what it does
|
|
17
|
+
- A **pseudocode translation** (simplified logic, not real syntax)
|
|
18
|
+
- **Quality warnings** with explanatory text (complexity, line count, parameter count)
|
|
19
|
+
- The **actual source code** (hidden by default, expandable)
|
|
20
|
+
|
|
21
|
+
Blocks are **nested** — directories contain files, files contain classes, classes contain functions. Click to drill down. Breadcrumbs to navigate back up. Color-coded by language.
|
|
22
|
+
|
|
23
|
+
### Code actions
|
|
24
|
+
|
|
25
|
+
Every analyzed block gets a toolbar with one-click actions:
|
|
26
|
+
|
|
27
|
+
| Button | What it does |
|
|
28
|
+
|--------|-------------|
|
|
29
|
+
| **Show Code** | Expand/collapse the source code inline |
|
|
30
|
+
| **Export Code** | Copy raw source to clipboard |
|
|
31
|
+
| **Copy for AI** | Copy source wrapped in a markdown code fence with context (block name, file path) — ready to paste into an AI assistant |
|
|
32
|
+
| **Replace Code** | Open an editor to paste modified code back into the source file |
|
|
33
|
+
|
|
34
|
+
**Replace Code** (available on functions, methods, and classes) lets you paste fixed or improved code — from an AI assistant, a code review, or your own edits — directly back into the original file. A `.bak` backup is created automatically before any write. The UI shows a confirmation step with success/error feedback, and all cached analysis is cleared so the block can be re-analyzed with the new code.
|
|
35
|
+
|
|
36
|
+
## Who it's for
|
|
37
|
+
|
|
38
|
+
You understand systems. You can read a schematic. You just can't read Python.
|
|
39
|
+
|
|
40
|
+
Codedocent is for project managers, founders, designers, analysts, auditors — anyone who needs to understand what a codebase does without learning to code.
|
|
41
|
+
|
|
42
|
+
## Quick start
|
|
43
|
+
|
|
44
|
+
### Requirements
|
|
45
|
+
|
|
46
|
+
- Python 3.10+
|
|
47
|
+
- [Ollama](https://ollama.com) installed and running
|
|
48
|
+
- A model pulled (e.g., `ollama pull gemma3:4b`)
|
|
49
|
+
|
|
50
|
+
### Install
|
|
51
|
+
```bash
|
|
52
|
+
git clone https://github.com/clanker-lover/codedocent.git
|
|
53
|
+
cd codedocent
|
|
54
|
+
pip install -e .
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Run
|
|
58
|
+
|
|
59
|
+
**Interactive mode** (recommended) — instant load, AI analyzes each block on click:
|
|
60
|
+
```bash
|
|
61
|
+
codedocent /path/to/any/codebase
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Your browser opens automatically. Click any block to drill down and trigger AI analysis.
|
|
65
|
+
|
|
66
|
+
**Full analysis mode** — analyzes everything upfront, outputs a static HTML file:
|
|
67
|
+
```bash
|
|
68
|
+
codedocent /path/to/any/codebase --full
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
**Text mode** — quick tree overview, no AI:
|
|
72
|
+
```bash
|
|
73
|
+
codedocent /path/to/any/codebase --text
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Options
|
|
77
|
+
|
|
78
|
+
| Flag | Description |
|
|
79
|
+
|------|-------------|
|
|
80
|
+
| `--full` | Analyze everything upfront, output static HTML |
|
|
81
|
+
| `--text` | Print text tree to terminal (no browser) |
|
|
82
|
+
| `--no-ai` | Skip AI summaries, show structure only |
|
|
83
|
+
| `--model MODEL` | Ollama model to use (default: `qwen3:14b`) |
|
|
84
|
+
| `--port PORT` | Port for interactive server (default: auto) |
|
|
85
|
+
| `--workers N` | Parallel AI workers for `--full` mode (default: 1) |
|
|
86
|
+
| `--output FILE` | Output filename for `--full` mode |
|
|
87
|
+
|
|
88
|
+
## Supported languages
|
|
89
|
+
|
|
90
|
+
Codedocent detects **23 file extensions** across these languages. Python and JavaScript/TypeScript get full AST parsing (functions, classes, methods, imports). All other languages get file-level analysis.
|
|
91
|
+
|
|
92
|
+
| Full parsing | File-level detection |
|
|
93
|
+
|-------------|---------------------|
|
|
94
|
+
| Python (.py) | C / C++ (.c, .cpp, .h, .hpp) |
|
|
95
|
+
| JavaScript (.js) | Rust (.rs) |
|
|
96
|
+
| TypeScript (.ts, .tsx) | Go (.go) |
|
|
97
|
+
| | Java (.java) |
|
|
98
|
+
| | Ruby (.rb) |
|
|
99
|
+
| | PHP (.php) |
|
|
100
|
+
| | Swift (.swift) |
|
|
101
|
+
| | Kotlin (.kt) |
|
|
102
|
+
| | Scala (.scala) |
|
|
103
|
+
| | HTML / CSS |
|
|
104
|
+
| | Config files (JSON, YAML, TOML) |
|
|
105
|
+
|
|
106
|
+
## How it works
|
|
107
|
+
|
|
108
|
+
**Interactive mode** starts a local server and opens your browser. The code tree loads instantly. When you click a block, it calls Ollama to analyze just that node — typically 1-2 seconds with a 4B model.
|
|
109
|
+
|
|
110
|
+
**Full mode** analyzes every node in priority order (directories → files → functions), with an optional `--workers` flag for parallel AI requests. Outputs a self-contained HTML file you can share.
|
|
111
|
+
|
|
112
|
+
All AI runs locally via Ollama. No data leaves your machine.
|
|
113
|
+
|
|
114
|
+
## AI models
|
|
115
|
+
|
|
116
|
+
Codedocent works with any model from the [Ollama library](https://ollama.com/library).
|
|
117
|
+
|
|
118
|
+
## Quality indicators
|
|
119
|
+
|
|
120
|
+
Each block shows a quality badge based on static analysis, with warnings that explain *why* — not just colored dots.
|
|
121
|
+
|
|
122
|
+
| Badge | Meaning |
|
|
123
|
+
|-------|---------|
|
|
124
|
+
| 🟢 Clean | Low complexity, no warnings |
|
|
125
|
+
| 🟡 Complex | Moderate complexity, long functions, or many parameters |
|
|
126
|
+
| 🔴 Warning | High complexity or very long code |
|
|
127
|
+
|
|
128
|
+
Warnings roll up through the tree: a file inherits the worst quality of its functions, and a directory inherits the worst quality of its files. Each level shows a count of problematic children (e.g., "Contains 2 high-risk functions"). Quality scoring works for all supported languages — Python files also get [radon](https://radon.readthedocs.io/) cyclomatic complexity analysis.
|
|
129
|
+
|
|
130
|
+
## Architecture
|
|
131
|
+
|
|
132
|
+
```
|
|
133
|
+
codedocent/
|
|
134
|
+
├── cli.py Command-line interface and entry point
|
|
135
|
+
├── scanner.py File discovery with .gitignore support
|
|
136
|
+
├── parser.py AST parsing via tree-sitter
|
|
137
|
+
├── analyzer.py AI summaries, quality scoring, caching
|
|
138
|
+
├── editor.py Code replacement with backup safety
|
|
139
|
+
├── renderer.py HTML generation (static + interactive)
|
|
140
|
+
├── server.py Local server for interactive mode
|
|
141
|
+
└── templates/
|
|
142
|
+
└── interactive.html Single-page app UI
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
## Current status
|
|
146
|
+
|
|
147
|
+
- Scanner, parser, renderer, analyzer, editor, server, CLI — all built and tested
|
|
148
|
+
- Interactive navigation with lazy AI analysis
|
|
149
|
+
- Static HTML full-analysis mode with parallel workers
|
|
150
|
+
- Code actions — Show Code, Export Code, Copy for AI, Replace Code
|
|
151
|
+
- Code replacement with `.bak` backup and cache invalidation
|
|
152
|
+
- Quality scoring with two-tier thresholds and warning rollup across the tree
|
|
153
|
+
- pip-installable package with `codedocent` CLI entry point
|
|
154
|
+
- 75 tests passing
|
|
155
|
+
- Code quality: pylint 10/10, bandit/flake8/mypy all clean
|
|
156
|
+
|
|
157
|
+
## License
|
|
158
|
+
|
|
159
|
+
MIT
|
|
160
|
+
|
|
161
|
+
## Contributing
|
|
162
|
+
|
|
163
|
+
This project is in active early development. Issues and ideas welcome.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""codedocent — code visualization for non-programmers."""
|