Skip to main content

Generate code graphs for Python projects

Project description

Python Code Graph Generator

Generate comprehensive code graphs for Python projects. This tool analyzes your Python codebase and creates a detailed JSON representation of its structure, dependencies, and relationships.

Python Code Graph Generator Logo

PyPI version Build Status License Python Versions

Features

  • 📊 Creates detailed code graphs for Python projects
  • 🔍 Analyzes functions, classes, variables, and imports
  • ⚡ Parallel processing for large codebases
  • 💾 Caching for improved performance
  • 🧩 Similar format to JavaScript/TypeScript code-graph-generator

Installation

pip install python-code-graph

Quick Start

from python_code_graph import create_code_graph

code_graph = create_code_graph(
    directory_path=".Path/to/my_project",
    output_json_path="output.json"
)

CLI USES

Basic options

python-code-graph /path/to/your/project -o output.json

Advance Options

python-code-graph [-h] [-o OUTPUT] [-n NAME] [-c CONCURRENCY] [-e EXCLUDE] [--no-cache] [--cache-dir CACHE_DIR] [-d] directory

Arguments:

directory: Directory containing Python files to analyze -o, --output: Output JSON file path (default: [project_name]_code_graph.json) -n, --name: Project name (default: directory name) -c, --concurrency: Number of parallel workers (default: 4) -e, --exclude: Patterns to exclude (can be specified multiple times) --no-cache: Disable caching --cache-dir: Directory to store cache files -d, --debug: Enable debug logging

Output Format

{
  "name": "project-name",
  "packages": [
    {
      "name": "package-name",
      "files": [
        {
          "path": "file/path.py",
          "types": [...],
          "variables": [...],
          "functions": [
            {
              "name": "function_name",
              "referencedIn": ["file/path.py"],
              "fileName": "path.py",
              "startLine": 10,
              "length": 5,
              "dependencies": [...],
              "types": [],
              "callsTo": ["other_function"]
            }
          ],
          "dependencies": [...],
          "exports": [...],
          "detailedDependencies": [...]
        }
      ],
      "dependencies": [],
      "exports": []
    }
  ]
}

More on Responce Format

npm version for same project

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

python_code_graph-0.1.2.tar.gz (14.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

python_code_graph-0.1.2-py3-none-any.whl (17.3 kB view details)

Uploaded Python 3

File details

Details for the file python_code_graph-0.1.2.tar.gz.

File metadata

  • Download URL: python_code_graph-0.1.2.tar.gz
  • Upload date:
  • Size: 14.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.10

File hashes

Hashes for python_code_graph-0.1.2.tar.gz
Algorithm Hash digest
SHA256 146d784b5d0d7688843e0ae976158af6b6a02c265668f21e2e193da62aef4d31
MD5 f6182edff331033803e58784e5fd5fcf
BLAKE2b-256 80ef4fcbe34017a039ed29a5136d4ed1a6def61654cc86794b1fadc780d182b6

See more details on using hashes here.

File details

Details for the file python_code_graph-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for python_code_graph-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ff0646b49dd1a3fe476e32085eb9a8bff4408d3fc7a1112b7fde3ec232d6f5e4
MD5 d3b31fda46c6a7c5e8724bd3dbff7885
BLAKE2b-256 13b536ab24922b1343f5fa348e875874d107e5b0c0238a9cbc6de42bd5abf17a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page