Skip to content

Ivesvdf/py2uml

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Py2UML

What is Py2UML

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

Examples

Example 1

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

which generates

Example 2

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

which generates

Example 3

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

which generates

Example 4

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

which generates

About

A script for converting python code to a UML-style class diagram

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages