# CodeGraph **Repository Path**: mirrors/CodeGraph ## Basic Information - **Project Name**: CodeGraph - **Description**: CodeGraph 是一个静态代码分析工具,它可以用你的代码结构创建一个图表,显示代码方法、模块、类等之间的依赖关系 - **Primary Language**: Python - **License**: MIT - **Default Branch**: main - **Homepage**: https://www.oschina.net/p/codegraph - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 1 - **Created**: 2023-04-18 - **Last Updated**: 2026-02-14 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ### CodeGraph - static code analyzator, that create a diagram with your code structure. ![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) **[Live Demo](https://xnuinside.github.io/codegraph/)** - Interactive visualization of [simple-ddl-parser](https://github.com/xnuinside/simple-ddl-parser) codebase Tool that creates a diagram with your code structure to show dependencies between code entities (methods, modules, classes and etc). 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. It is based only on lexical and syntax parsing, so it doesn't need to install all your code dependencies. ### Interactive Visualization ![Interactive Code Visualization](docs/img/interactive_code_visualization.png) **Zoom, Pan & Drag** - Use mouse wheel to zoom, drag background to pan, drag nodes to reposition them. ### Search & Highlight ![Node Search](docs/img/node_search.png) **Search with Autocomplete** - Press `Ctrl+F` (or `Cmd+F` on Mac) to search. Results show node type with color coding. ![Highlight Nodes](docs/img/highlight_nodes.png) **Highlight Connections** - Click on any node to highlight it and all connected nodes. Others will be dimmed. ### Node Information ![Node Information](docs/img/node_information.png) **Tooltips** - Hover over any node to see details: type, parent module, full path, lines of code, and connection counts (links in/out). ### Links Count ![Links Count](docs/img/links_count.png) **Links Count Panel** - Find nodes by their connection count. Filter by "links in" or "links out" with configurable threshold. ### Unlinked Modules ![Unlinked Nodes](docs/img/listing_unlinked_nodes.png) **Unlinked Panel** - Shows modules with no connections. Click to navigate to them on the graph. ### Massive Objects Detection ![Massive Objects](docs/img/massive_objects_detection.png) **Massive Objects Panel** - Find large code entities by lines of code. Filter by type (modules, classes, functions) with configurable threshold. ### Display Settings ![Display Settings](docs/img/graph_display_settings.png) **Display Filters** - Show/hide nodes by type (Modules, Classes, Functions, External) and links by type (Module→Module, Module→Entity, Dependencies). ### UI Tips ![UI Tips](docs/img/tips_in_ui.png) **Built-in Help** - Legend and keyboard shortcuts are always visible in the UI. --- ### Installation ```console pip install codegraph ``` ### Usage ```console codegraph /path/to/your_python_code ``` This will generate an interactive HTML visualization and open it in your browser. ### CLI Options | Option | Description | |--------|-------------| | `--output PATH` | Custom output path for HTML file (default: `./codegraph.html`) | | `--csv PATH` | Export graph data to CSV file | | `--matplotlib` | Use legacy matplotlib visualization instead of D3.js | | `-o, --object-only` | Print dependencies to console only, no visualization | ### CSV Export Export graph data to CSV for analysis in spreadsheets or other tools: ```console codegraph /path/to/code --csv output.csv ``` CSV columns: - `name` - Entity name - `type` - module / function / class / external - `parent_module` - Parent module (for functions/classes) - `full_path` - File path - `links_out` - Outgoing dependencies count - `links_in` - Incoming dependencies count - `lines` - Lines of code ## Changelog See [CHANGELOG.md](CHANGELOG.md) for full version history.