Metadata-Version: 2.4
Name: codegrapher
Version: 0.3.0
Summary: Code that graphs code
Project-URL: Homepage, https://github.com/LaurEars/codegrapher
Project-URL: Repository, https://github.com/LaurEars/codegrapher
Project-URL: Issues, https://github.com/LaurEars/codegrapher/issues
Author: Laura Rupprecht
License: The MIT License (MIT)
        
        Copyright (c) 2026 Laura Rupprecht
        
        Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
        documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
        rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
        persons to whom the Software is furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
        Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
        WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
        COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
        OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
License-File: LICENSE
Keywords: ast,call-graph,code,documentation,graph,graphviz
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Documentation
Requires-Python: >=3.8
Requires-Dist: click>=7.0
Requires-Dist: graphviz>=0.4.2
Provides-Extra: dev
Requires-Dist: coverage>=5.0; extra == 'dev'
Requires-Dist: pytest-cov>=4.0.0; extra == 'dev'
Requires-Dist: pytest>=7.0.0; extra == 'dev'
Description-Content-Type: text/x-rst

codegrapher
===========

.. image:: https://github.com/LaurEars/codegrapher/actions/workflows/main.yaml/badge.svg
    :target: https://github.com/LaurEars/codegrapher/actions/workflows/main.yaml


Code that graphs code
---------------------
Uses the python `AST <https://docs.python.org/3/library/ast.html>`_ to parse Python source code and build a call graph.


Output
------
An example of the current output of the parser parsing itself.

.. image:: docs/codegrapher.png
    :target: docs/codegrapher.png
    :align: center
    :width: 100 %
    :alt: parser.py


Installation
------------

.. code:: bash

    pip install codegrapher


To generate graphs, `graphviz <http://www.graphviz.org/Download.php>`_ must be installed.


Usage
-----

At the command line
~~~~~~~~~~~~~~~~~~~
To parse a file and output results to the console:

.. code:: bash

    codegrapher path/to/file.py --printed


To parse a file and output results to a file:

.. code:: bash

    codegrapher path/to/file.py --output output_file_name --output-type png

To analyze a directory of files, along with all files it contains:

.. code:: bash

    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 :

.. code:: 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):

.. code:: python

    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 <http://en.wikipedia.org/wiki/DOT_%28graph_description_language%29>`_ `name.gv`

More documentation for the Python module can be found at
`Read the Docs <http://codegrapher.readthedocs.org/en/latest/>`_.
