/dict2uml

Python library that prints a dict as PlantUML code.

Primary LanguagePythonMIT LicenseMIT

dict2uml

Build Status PyPI version GitHub license GitHub stars GitHub forks Code Health Coverage Status

Python library that prints a Python dict as PlantUML code or as an inline picture in a Jupyter Notebook.

Heavily inspired by json-to-plantuml by meteorbites and IPlantUML by John B Nelson.

Fork TODO

  • This is a poor implementation and creates ugly UML diagrams. The json-to-plantuml does a better job. So, you can install that and call system process from python to run and return the diagram or uml text.

Installation

Install plantuml, for example with brew install plantuml. The location should be /usr/local/bin/plantuml. This is hardcoded for now, so if you need to change it, please install from source.

pip install dict2uml

Optionally install jupyter to generate these pictures directly in a notebook.

pip install jupyter

Usage

This can be used either at command line or in a notebook. You can generate an SVG or print the code that generated the diagram.

Setup

import dict2uml
d = {"beers": ["Heineken","Budweiser","Guinness"]}

Print SVG

To print the class diagram of the dict d in Jupyter, do

dict2uml.dict2svg(d)

Print PlantUML source code

Print the source code for the PlantUML class diagram.

print(dict2uml.dict2plantuml(d))

Example

cat example.json | python dict2uml.py | plantuml -pipe | open -a Preview.app -f

example

References