A script for converting python code to a UML-style class diagram.
The script will output graphviz code which can be piped into a graphviz engine, like dot.
At the moment, this should be used like
find src/ -type f -iname "*.py" | xargs python py2uml.py | dot -T png -o test.png
from the directory in which the file that's normally executed is located. (this is necessary to get the imports in your files right)
Later on, support for entire directories will appear...
Please note that your code does have to compile (all files will be imported).
Command:
../../py2uml.py animals.py | dot -T png -o output.png
animals.py:
class Animal:
def __init__(self):
pass
def makeNoise():
pass
class Dog(Animal):
def wagTail():
pass
def __somePrivateMethod():
pass
class Cat(Animal):
pass
Command:
../../py2uml.py *.py | dot -T png -o output.png
animal.py:
class Animal:
def __init__(self):
pass
def makeNoise():
pass
cat.py:
from animal import Animal
class Cat(Animal):
pass
dog.py:
from animal import Animal
class Dog(Animal):
def wagTail():
pass
def __somePrivateMethod():
pass
Command:
../../py2uml.py --names-only *.py | dot -T png -o output.png
animal.py:
class Animal:
def __init__(self):
pass
def makeNoise():
pass
cat.py:
from animal import Animal
class Cat(Animal):
pass
dog.py:
from animal import Animal
class Dog(Animal):
def wagTail():
pass
def __somePrivateMethod():
pass
Command:
../../py2uml.py --max-methods=2 *.py | dot -T png -o output.png
animal.py:
class Animal:
def __init__(self):
pass
def makeNoise():
pass
cat.py:
from animal import Animal
class Cat(Animal):
pass
dog.py:
from animal import Animal
class Dog(Animal):
def wagTail():
pass
def __somePrivateMethod():
pass