Introduction to Codegrapher¶
codegrapher¶
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
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