martisak / dict2uml

Python library that prints a dict as PlantUML code.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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.

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

About

Python library that prints a dict as PlantUML code.

License:MIT License


Languages

Language:Python 96.2%Language:Makefile 3.8%