Skip to content

Commit 8709ecb

Browse files
committed
update README.md, add publish to github pages demo
1 parent ecb67af commit 8709ecb

23 files changed

+577
-485
lines changed

.github/workflows/main.yml

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ on:
66
pull_request:
77
branches: [ main ]
88

9+
permissions:
10+
contents: read
11+
pages: write
12+
id-token: write
13+
914
jobs:
1015
lint:
1116
runs-on: ubuntu-latest
@@ -44,24 +49,37 @@ jobs:
4449
run: |
4550
pytest tests/ -v
4651
47-
tox:
52+
deploy-demo:
4853
runs-on: ubuntu-latest
49-
needs: [lint]
54+
needs: [tests]
55+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
56+
environment:
57+
name: github-pages
58+
url: ${{ steps.deployment.outputs.page_url }}
5059
steps:
5160
- uses: actions/checkout@v4
52-
- name: Set up Python versions
61+
- name: Set up Python 3.12
5362
uses: actions/setup-python@v5
5463
with:
55-
python-version: |
56-
3.9
57-
3.10
58-
3.11
59-
3.12
60-
3.13
61-
- name: Install tox
64+
python-version: "3.12"
65+
- name: Install codegraph
6266
run: |
6367
python -m pip install --upgrade pip
64-
pip install tox
65-
- name: Run tox
68+
pip install matplotlib networkx click
69+
pip install -e .
70+
- name: Clone simple-ddl-parser for demo
71+
run: |
72+
git clone --depth 1 https://github.com/xnuinside/simple-ddl-parser.git /tmp/simple-ddl-parser
73+
- name: Generate demo page
6674
run: |
67-
tox
75+
mkdir -p docs
76+
codegraph /tmp/simple-ddl-parser/simple_ddl_parser --output docs/index.html
77+
- name: Setup Pages
78+
uses: actions/configure-pages@v4
79+
- name: Upload artifact
80+
uses: actions/upload-pages-artifact@v3
81+
with:
82+
path: 'docs'
83+
- name: Deploy to GitHub Pages
84+
id: deployment
85+
uses: actions/deploy-pages@v4

CHANGELOG.md

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,22 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [1.0.1] - 2025-01-17
9+
10+
### Added
11+
12+
- **Live Demo**: Interactive demo available at [xnuinside.github.io/codegraph](https://xnuinside.github.io/codegraph/)
13+
- **GitHub Pages CI/CD**: Automatic demo deployment on merge to main
14+
15+
### Changed
16+
17+
- **Import-based module connections**: Module-to-module links now created based on imports, not just entity usage. This ensures connections are shown even when importing variables or constants (not just functions/classes)
18+
- **Renamed "Unused Modules" to "Unlinked"**: Panel now shows only modules with no connections at all (neither incoming nor outgoing), instead of just modules not imported by others
19+
20+
### Fixed
21+
22+
- Fixed missing module connections when imported names are variables (like `dialect_by_name`) rather than functions/classes
23+
824
## [1.0.0] - 2025-01-17
925

1026
### Added
@@ -57,7 +73,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
5773
- KeyError when analyzing codebases with external imports not in the analyzed path
5874
- Now gracefully skips modules not found in the analyzed codebase
5975
- Comma-separated imports now properly parsed (e.g., `from package import a, b, c`)
60-
- Fixed missing connections when imports use comma-separated syntax
76+
- Multi-line imports with parentheses now properly parsed
77+
- Fixed missing connections when imports use comma-separated or multi-line syntax
78+
79+
### Added
80+
- **Class inheritance detection**: Classes now show connections to their base classes
81+
- Supports single and multiple inheritance: `class Child(Base1, Base2)`
82+
- Supports multi-line inheritance declarations
83+
- **`__init__.py` support**: Now includes `__init__.py` files in analysis
84+
- Re-export connections from `__init__.py` are shown as dependencies
85+
- **Unused Modules Panel**: Shows list of modules not imported by any other module
86+
- Click on module name to navigate and zoom to it on the graph
87+
- **Full Path in Tooltip**: Hovering over modules now shows relative path (e.g., "Full Path: tests/test_comments.py")
88+
89+
### Changed
90+
- Replaced print statements with logging/click.echo for proper CLI output
6191

6292
### Testing
6393
- Added comprehensive test suite for graph generation (`tests/test_graph_generation.py`)

README.md

Lines changed: 43 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -2,138 +2,70 @@
22

33
![badge1](https://img.shields.io/pypi/v/codegraph) ![badge2](https://img.shields.io/pypi/l/codegraph) ![badge3](https://img.shields.io/pypi/pyversions/codegraph)![workflow](https://github.com/xnuinside/codegraph/actions/workflows/main.yml/badge.svg)
44

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
86

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.
910

10-
### Install codegraph
11-
```console
12-
13-
pip install codegraph
11+
### Interactive Visualization
1412

15-
```
13+
![Interactive Code Visualization](docs/img/interactive_code_visualization.png)
1614

17-
### Analyze your code
15+
**Zoom, Pan & Drag** - Use mouse wheel to zoom, drag background to pan, drag nodes to reposition them.
1816

19-
codegraph - name of command line tool for CodeGrapg
17+
### Search & Highlight
2018

21-
```console
19+
![Node Search](docs/img/node_search.png)
2220

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.
2522

26-
# or for one file
23+
![Highlight Nodes](docs/img/highlight_nodes.png)
2724

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.
2926

30-
```
27+
### Node Information
3128

32-
your_python_code - module with your python code
29+
![Node Information](docs/img/node_information.png)
3330

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.
3532

36-
codegraph /Users/myuser/codegraph/codegraph
33+
### Unlinked Modules
3734

38-
Pass '-o' flag if you want only print dependencies in console and don't want graph visualisation
35+
![Unlinked Nodes](docs/img/listing_unlinked_nodes.png)
3936

40-
codegraph /path/to/your_python_code -o
37+
**Unlinked Panel** - Shows modules with no connections. Click to navigate to them on the graph.
4138

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
4440

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+
![UI Tips](docs/img/tips_in_ui.png)
4842

49-
![Graph visualisation](https://github.com/xnuinside/codegraph/blob/main/docs/img/graph_visualisation.png "Graph visualisation")
43+
**Built-in Help** - Legend and keyboard shortcuts are always visible in the UI.
5044

51-
![ Code with not used module](https://github.com/xnuinside/codegraph/blob/main/docs/img/code_with_trash_module.png "Code with not used module")
45+
---
5246

53-
![Code there all modules linked together](https://github.com/xnuinside/codegraph/blob/main/docs/img/normal_code.png "Code there all modules linked together")
47+
### Installation
5448

55-
### TODO
49+
```console
50+
pip install codegraph
51+
```
5652

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 |
6268

6369
## 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.

build.sh

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,4 @@
11
#!/bin/bash
2-
# Build script for codegraph
3-
# https://github.com/python-poetry/poetry/pull/3733
4-
5-
set -e
6-
7-
# Create README with changelog from CHANGELOG.md
8-
sed '/## Changelog/q' README.md > new_README.md
9-
# Skip the header line "# Changelog" from CHANGELOG.md and append the rest
10-
tail -n +3 CHANGELOG.md >> new_README.md
11-
rm README.md
12-
mv new_README.md README.md
13-
14-
# Convert to RST for PyPI
15-
m2r2 README.md
16-
mv README.rst docs/README.rst
172

183
# Build package
194
rm -rf dist

0 commit comments

Comments
 (0)