Code that graphs code
Project description
Code that graphs code
Uses the python AST to parse Python source code and build a call graph.
Output
An example of the current output of the parser parsing itself.
Installation
pip install codegrapher
To generate graphs, graphviz must be installed.
Usage
At the command line
To parse a file and output results to the console:
codegrapher path/to/file.py --printed
To parse a file and output results to a file:
codegrapher path/to/file.py --output output_file_name --output-type png
To analyze a directory of files, along with all files it contains:
codegrapher -r path/to/directory --output multiple_file_analysis
And if you have a list of functions that aren’t useful in your graph, add it to a .cg_ignore file:
# cg_ignore file # all lines beginning with '#' are ignored # every function calls this, so it's not helpful in my graph: log_error # I don't want to see this in my graph: parse lower
Then add the –ignore flag to your command. Using the flag –remove-builtins provides the same functionality for ignoring items found in __builtins__.
As a Python module
To easily parse code in Python :
from codegrapher.parser import FileObject
file_object = FileObject('path/to/file.py')
file_object.visit()
And then to add that code to a graph and render it (using graphviz):
from codegrapher.graph import FunctionGrapher
graph = FunctionGrapher()
graph.add_file_to_graph(file_object)
graph.name = 'name.gv'
graph.format = 'png'
graph.render()
Which will produce your code as a png file, name.gv.png, along with a dot file name.gv
More documentation for the Python module can be found at Read the Docs.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file codegrapher-0.3.0.tar.gz.
File metadata
- Download URL: codegrapher-0.3.0.tar.gz
- Upload date:
- Size: 56.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
46ec21fc5398438f27a7112ef957d66eadbf3aeaea8a334722fcfccb95c7ad6a
|
|
| MD5 |
587c6330554fefa281789e3195031ba9
|
|
| BLAKE2b-256 |
995be82d497a79e8e05b88a00137fd062de0d5db468060bcabc957c91a278fcc
|
Provenance
The following attestation bundles were made for codegrapher-0.3.0.tar.gz:
Publisher:
publish.yaml on LaurEars/codegrapher
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
codegrapher-0.3.0.tar.gz -
Subject digest:
46ec21fc5398438f27a7112ef957d66eadbf3aeaea8a334722fcfccb95c7ad6a - Sigstore transparency entry: 1679162852
- Sigstore integration time:
-
Permalink:
LaurEars/codegrapher@083e43ab9bdd5a4423a72106c04dabef729f4799 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/LaurEars
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@083e43ab9bdd5a4423a72106c04dabef729f4799 -
Trigger Event:
release
-
Statement type:
File details
Details for the file codegrapher-0.3.0-py3-none-any.whl.
File metadata
- Download URL: codegrapher-0.3.0-py3-none-any.whl
- Upload date:
- Size: 10.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a82ef9aad5dce3c666b7eb017adc30e2d51aef93d1733e53f227b80e76f6bb44
|
|
| MD5 |
16e8f9c64cbc7e93962749b1127e1b70
|
|
| BLAKE2b-256 |
eb20dc197259c149d743bde592a0a8cb298501341a2a6dcb345b871cb38b2408
|
Provenance
The following attestation bundles were made for codegrapher-0.3.0-py3-none-any.whl:
Publisher:
publish.yaml on LaurEars/codegrapher
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
codegrapher-0.3.0-py3-none-any.whl -
Subject digest:
a82ef9aad5dce3c666b7eb017adc30e2d51aef93d1733e53f227b80e76f6bb44 - Sigstore transparency entry: 1679162958
- Sigstore integration time:
-
Permalink:
LaurEars/codegrapher@083e43ab9bdd5a4423a72106c04dabef729f4799 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/LaurEars
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@083e43ab9bdd5a4423a72106c04dabef729f4799 -
Trigger Event:
release
-
Statement type: