|
2 | 2 |
|
3 | 3 |    |
4 | 4 |
|
5 | | -Tool that create a digram with your code structure to show dependencies between code entities (methods, modules, classes and etc). |
6 | | -Main advantage of CodeGraph, that is does not execute the code itself. You not need to activate any environments or install dependencies to analyse the target code. |
7 | | -It is based only on lex and syntax parse, so it not need to install all your code dependencies. |
| 5 | +**[Live Demo](https://xnuinside.github.io/codegraph/)** - Interactive visualization of [simple-ddl-parser](https://github.com/xnuinside/simple-ddl-parser) codebase |
8 | 6 |
|
| 7 | +Tool that creates a diagram with your code structure to show dependencies between code entities (methods, modules, classes and etc). |
| 8 | +Main advantage of CodeGraph is that it does not execute the code itself. You don't need to activate any environments or install dependencies to analyze the target code. |
| 9 | +It is based only on lexical and syntax parsing, so it doesn't need to install all your code dependencies. |
9 | 10 |
|
10 | | -### Install codegraph |
11 | | -```console |
12 | | - |
13 | | - pip install codegraph |
| 11 | +### Interactive Visualization |
14 | 12 |
|
15 | | -``` |
| 13 | + |
16 | 14 |
|
17 | | -### Analyze your code |
| 15 | +**Zoom, Pan & Drag** - Use mouse wheel to zoom, drag background to pan, drag nodes to reposition them. |
18 | 16 |
|
19 | | -codegraph - name of command line tool for CodeGrapg |
| 17 | +### Search & Highlight |
20 | 18 |
|
21 | | -```console |
| 19 | + |
22 | 20 |
|
23 | | - codegraph /path/to/your_python_code |
24 | | - # path must be absolute |
| 21 | +**Search with Autocomplete** - Press `Ctrl+F` (or `Cmd+F` on Mac) to search. Results show node type with color coding. |
25 | 22 |
|
26 | | - # or for one file |
| 23 | + |
27 | 24 |
|
28 | | - codegraph /path/to/your_python_code |
| 25 | +**Highlight Connections** - Click on any node to highlight it and all connected nodes. Others will be dimmed. |
29 | 26 |
|
30 | | -``` |
| 27 | +### Node Information |
31 | 28 |
|
32 | | -your_python_code - module with your python code |
| 29 | + |
33 | 30 |
|
34 | | -For example, if I put codegraph in my user home directory path will be: |
| 31 | +**Tooltips** - Hover over any node to see details: type, parent module, full path, and connection count. |
35 | 32 |
|
36 | | - codegraph /Users/myuser/codegraph/codegraph |
| 33 | +### Unlinked Modules |
37 | 34 |
|
38 | | -Pass '-o' flag if you want only print dependencies in console and don't want graph visualisation |
| 35 | + |
39 | 36 |
|
40 | | - codegraph /path/to/your_python_code -o |
| 37 | +**Unlinked Panel** - Shows modules with no connections. Click to navigate to them on the graph. |
41 | 38 |
|
42 | | -If you want to change view and play with graph output - you can check 'vizualyzer.py' |
43 | | -and play with matplotlib and networkX settings. |
| 39 | +### UI Tips |
44 | 40 |
|
45 | | -### Colors meanings |
46 | | -In default view - **red line** show dependencies between entities in different modules. |
47 | | -**Green** - links between objects/functions inside same module. |
| 41 | + |
48 | 42 |
|
49 | | - |
| 43 | +**Built-in Help** - Legend and keyboard shortcuts are always visible in the UI. |
50 | 44 |
|
51 | | - |
| 45 | +--- |
52 | 46 |
|
53 | | - |
| 47 | +### Installation |
54 | 48 |
|
55 | | -### TODO |
| 49 | +```console |
| 50 | +pip install codegraph |
| 51 | +``` |
56 | 52 |
|
57 | | - 1. Create normal readme |
58 | | - 2. Add tests |
59 | | - 3. Work on visual part of Graph (now it is not very user friendly) |
60 | | - 4. Add support to variables (names) as entities |
61 | | - 5. Split usage & inheritance as a different cases |
| 53 | +### Usage |
| 54 | + |
| 55 | +```console |
| 56 | +codegraph /path/to/your_python_code |
| 57 | +``` |
| 58 | + |
| 59 | +This will generate an interactive HTML visualization and open it in your browser. |
| 60 | + |
| 61 | +### CLI Options |
| 62 | + |
| 63 | +| Option | Description | |
| 64 | +|--------|-------------| |
| 65 | +| `--output PATH` | Custom output path for HTML file (default: `./codegraph.html`) | |
| 66 | +| `--matplotlib` | Use legacy matplotlib visualization instead of D3.js | |
| 67 | +| `-o, --object-only` | Print dependencies to console only, no visualization | |
62 | 68 |
|
63 | 69 | ## Changelog |
64 | | -All notable changes to this project will be documented in this file. |
65 | | - |
66 | | -The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), |
67 | | -and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). |
68 | | - |
69 | | -## [1.0.0] - 2025-01-17 |
70 | | - |
71 | | -### Added |
72 | | - |
73 | | -**Interactive D3.js Visualization (New Default)** |
74 | | -- D3.js visualization is now the default instead of matplotlib |
75 | | -- Zoom & Pan: Mouse wheel to zoom, drag background to pan |
76 | | -- Drag nodes: Reposition individual nodes by dragging |
77 | | -- Collapse/Expand: Click on modules or entities to collapse/expand their children |
78 | | -- Double-click: Focus and zoom to any node |
79 | | -- Tooltips: Hover over nodes to see details (type, parent module, connection count) |
80 | | -- Auto zoom-to-fit: Graph automatically fits to screen after loading |
81 | | - |
82 | | -**Module-to-Module Connections** |
83 | | -- Orange links now show dependencies between .py files |
84 | | -- Visual representation of which modules depend on which |
85 | | -- Module connections are always visible even when entities are collapsed |
86 | | - |
87 | | -**Search with Autocomplete** |
88 | | -- Search box at the top center of the visualization |
89 | | -- Ctrl+F (Cmd+F on Mac) to focus search |
90 | | -- Autocomplete dropdown with up to 10 matching results |
91 | | -- Results show node type (module/entity/external) with color coding |
92 | | -- Arrow keys to navigate, Enter to select, Esc to close |
93 | | -- Highlighting: Selected node and its connections are highlighted, others dimmed |
94 | | -- Info panel shows number of connected nodes |
95 | | - |
96 | | -**Visual Design** |
97 | | -- Modules: Green squares (larger) |
98 | | -- Entities: Blue circles (functions/classes) |
99 | | -- External dependencies: Gray circles |
100 | | -- Module-to-Module links: Orange, thick (3px) |
101 | | -- Module-to-Entity links: Green, dashed |
102 | | -- Entity-to-Dependency links: Red |
103 | | -- Statistics panel showing module count, entity count, and module connections |
104 | | -- Legend explaining all node and link types |
105 | | -- Dark theme with high contrast |
106 | | - |
107 | | -**CLI Options** |
108 | | -- `--matplotlib` flag to use legacy matplotlib visualization |
109 | | -- `--output PATH` to specify custom output path for HTML file |
110 | | -- Default output: `./codegraph.html` (current working directory) |
111 | | - |
112 | | -### Changed |
113 | | -- Default visualization changed from matplotlib to D3.js |
114 | | -- `draw_graph()` now generates interactive HTML instead of matplotlib window |
115 | | -- Renamed `draw_graph()` to `draw_graph_matplotlib()` for legacy visualization |
116 | | - |
117 | | -### Fixed |
118 | | -- KeyError when analyzing codebases with external imports not in the analyzed path |
119 | | -- Now gracefully skips modules not found in the analyzed codebase |
120 | | -- Comma-separated imports now properly parsed (e.g., `from package import a, b, c`) |
121 | | -- Fixed missing connections when imports use comma-separated syntax |
122 | | - |
123 | | -### Testing |
124 | | -- Added comprehensive test suite for graph generation (`tests/test_graph_generation.py`) |
125 | | -- Tests for import parsing: simple imports, comma-separated, aliased imports |
126 | | -- Tests for CodeGraph connections between modules |
127 | | -- Tests for D3.js format conversion |
128 | | -- Tests verifying codegraph can analyze its own codebase |
129 | | -- Support for Python 3.9, 3.10, 3.11, 3.12, 3.13 |
130 | | -- Added `tox.ini` for multi-version testing |
131 | | -- Added GitHub Actions CI matrix for all supported Python versions |
132 | | - |
133 | | -## [0.1.0] - Previous |
134 | | - |
135 | | -### Added |
136 | | -- Initial matplotlib visualization |
137 | | -- Basic dependency graph generation |
138 | | -- CLI interface with click |
139 | | -- Support for Python 3.12+ |
| 70 | + |
| 71 | +See [CHANGELOG.md](CHANGELOG.md) for full version history. |
0 commit comments