Adam Feuer -> PyUMLGraph

PyUMLGraph - Declarative Drawing of UML diagrams for Python

PyUMLGraph is a Python debugger that produces UML diagrams by inspecting running Python programs. The output is in Graphviz's dot language, and dot can produce pictures in many popular formats, such as PNG, PDF, SVG, and others. The UML diagrams can contain information about class inheritance relationships, references to other classes, class methods and return types, as well as class attributes and types.

class Person:
   def __init__(self):
      pass

class Employee(Person):
   def __init__(self):
      pass

class Client(Person):
   def __init__(self):
      pass

if __name__ == "__main__":
   person = Person()
   employee = Employee()
   client = Client()

Sample use from the command line (Linux):

  $pyumlgraph -o simple.dot simple.py
  $dot -Tpng -o simple.png simple.dot
Here's the output, simple.dot. You can find the simple.py file in PyUMLGraph's examples/ directory.

Here's another example diagram, produced using example1.py:

Here are the commandline options:

-o          write dot language UML output to this file

--help                  Display this help then exit.
--version               Output version information then exit.

--types                 Include common types (str, int, dict, etc.)
--methods               Show class methods
--attributes            Show class attributes
--references            Distinguish between self and local references
--all                   Equivalent to --types --methods --attributes --references

--nodefillcolor= Set the node fill color to this string.
                         can be Unix color name or a hex 3-tuple.

--bgcolor=       Set the diagram's background color to this string.
                         can be Unix color name or a hex
                        3-tuple.

License

PyUMLGraph is free software provided under the Gnu Public License - see the file COPYING.txt.

Installation

PyUMLGraph requires Python 2.2 or more recent. Make sure this is installed, unpack PyUMLGraph to a convenient location and run
python setup.py install
Note that under Windows, you may have to use the --prefix= and --install-scripts options to tell setup.py where to put the pyumlgraph.py script.

Download

@@@DOWNLOAD_LINKS@@@

Credits

PyUMLGraph is inspired by Diomidis Spinellis' UMLGraph, which can generate UML diagrams for Java software.

Thanks to Paul DuPuy for the idea and encouragement, and Troy Frever for pointing out that it could be done by writing a debugger.

If you find PyUMLGraph to be useful, please drop me a note to let me know.

--Adam Feuer <adamf at pobox dot com>

Adam Feuer's homepage