@@ -38,7 +38,7 @@ If you like tools around PlantUML, you may also be interested in this [lucsorel/
3838
3939# Install
4040
41- Install from the github repository :
41+ Install from PyPI :
4242
4343* with ` pip ` :
4444
@@ -60,22 +60,16 @@ pipenv install py2puml
6060
6161# Usage
6262
63- For example, to create the diagram of the classes used by ` py2puml ` :
64-
65- * import the py2puml function in your script (see [ py2puml/example.py] ( py2puml/example.py ) ):
63+ ## CLI
6664
67- ``` python
68- from py2puml.py2puml import py2puml
65+ Once ` py2puml ` is installed at the system level, an eponymous command is available in your environment shell.
6966
70- # outputs the PlantUML content in the terminal
71- print (' ' .join(py2puml(' py2puml/domain' , ' py2puml.domain' )))
72-
73- # writes the PlantUML content in a file
74- with open (' py2puml/domain.puml' , ' w' ) as puml_file:
75- puml_file.writelines(py2puml(' py2puml/domain' , ' py2puml.domain' ))
67+ For example, to create the diagram of the classes used by ` py2puml ` , one can use:
68+ ``` sh
69+ py2puml py2puml/domain py2puml.domain
7670```
7771
78- * running it ( ` python3 -m py2puml.example ` ) will output the PlantUML diagram in the terminal and write it in a file
72+ This will output the following PlantUML script:
7973
8074``` plantuml
8175@startuml
@@ -114,9 +108,54 @@ py2puml.domain.umlrelation.UmlRelation *-- py2puml.domain.umlrelation.RelType
114108@enduml
115109```
116110
117- Which renders like this:
111+ Using PlantUML, this script renders this diagram:
112+
113+ ![ py2puml UML Diagram] ( https://www.plantuml.com/plantuml/png/ZP91IyGm48Nl-HKvBsmF7iiUTbaA1jnMQZs9I7OxIY19Qp8H5jV_xZIse5GsFULrQBvvCozRZz9XC9gTjFIUz-URdhwojZDIsOnah6UFHkyGdJe61Fx9EBVIGCuzEj9uxaVzbSRi1n4HSWBwdDyfZq-_cpnVOIa4Cw04dJCph--jJPa16qns07C4Dxl_8NM0HG1oKD0P2IR2fa5-qCC8mu__t7UW9QhEPZNeXhON6VlgS5yzY4PKPSvNL13bRL6BPbVkYvnlBdC_SnvvgaSTcRuBxWGlSIbJMjAz0SRItm17BzGc6TzglLxqL5WYlCs5GAbkBB5_CdCzuoKk4Y6pPJkFNj9niotObkhi6m00 )
114+
115+ For a full overview of the CLI, run:
116+
117+ ``` sh
118+ py2puml --help
119+ ```
120+
121+ The CLI can also be launched as a python module:
122+
123+ ``` sh
124+ python -m py2puml py2puml/domain py2puml.domain
125+ ```
126+
127+ Pipe the result of the CLI with a PlantUML server for instantaneous documentation (rendered by ImageMagick):
128+
129+ ``` sh
130+ # runs a local PlantUML server from a docker container:
131+ docker run -d -p 1234:8080 --name plantumlserver plantuml/plantuml-server:jetty
132+
133+ py2puml py2puml/domain py2puml.domain | curl -X POST --data-binary @- http://localhost:1234/svg/ --output - | display
134+
135+ # stops the container when you don't need it anymore, restarts it later, removes it
136+ docker stop plantumlserver
137+ docker start plantumlserver
138+ docker rm plantumlserver
139+ ```
140+
141+ ## Python API
142+
143+ For example, to create the diagram of the classes used by ` py2puml ` :
144+
145+ * import the py2puml function in your script (see [ py2puml/example.py] ( py2puml/example.py ) ):
146+
147+ ``` python
148+ from py2puml.py2puml import py2puml
149+
150+ # outputs the PlantUML content in the terminal
151+ print (' ' .join(py2puml(' py2puml/domain' , ' py2puml.domain' )))
152+
153+ # writes the PlantUML content in a file
154+ with open (' py2puml/domain.puml' , ' w' ) as puml_file:
155+ puml_file.writelines(py2puml(' py2puml/domain' , ' py2puml.domain' ))
156+ ```
157+ * running it (` python3 -m py2puml.example ` ) will output the previous PlantUML diagram in the terminal and write it in a file.
118158
119- ![ ] ( https://www.plantuml.com/plantuml/png/ZP91IyGm48Nl-HKvBsmF7iiUTbaA1jnMQZs9I7OxIY19Qp8H5jV_xZIse5GsFULrQBvvCozRZz9XC9gTjFIUz-URdhwojZDIsOnah6UFHkyGdJe61Fx9EBVIGCuzEj9uxaVzbSRi1n4HSWBwdDyfZq-_cpnVOIa4Cw04dJCph--jJPa16qns07C4Dxl_8NM0HG1oKD0P2IR2fa5-qCC8mu__t7UW9QhEPZNeXhON6VlgS5yzY4PKPSvNL13bRL6BPbVkYvnlBdC_SnvvgaSTcRuBxWGlSIbJMjAz0SRItm17BzGc6TzglLxqL5WYlCs5GAbkBB5_CdCzuoKk4Y6pPJkFNj9niotObkhi6m00 )
120159
121160# Tests
122161
@@ -130,6 +169,7 @@ python3 -m pytest -v
130169
131170# Changelog
132171
172+ * ` 0.4.0 ` : add a simple CLI
133173* ` 0.3.1 ` : inspect sub-folders recursively
134174* ` 0.3.0 ` : handle classes derived from namedtuples (attribute types are ` any ` )
135175* ` 0.2.0 ` : handle inheritance relationships and enums. Unit tested
@@ -143,6 +183,7 @@ Unless stated otherwise all works are licensed under the [MIT license](http://sp
143183
144184* [ Luc Sorel-Giffo] ( https://github.com/lucsorel )
145185* [ Doyou Jung] ( https://github.com/doyou89 )
186+ * [ Julien Jerphanion] ( https://github.com/jjerphan )
146187
147188Pull-requests are welcome and will be processed on a best-effort basis.
148189
0 commit comments