sphinx-plantuml can render PlantUML figure in your Sphinx document without any dependencies in an instant
you can install sphinx-plantuml by pip
.
python3 -m pip install sphinx-plantuml
please add sphinxcontrib.plantuml
into your conf.py
file.
extensions = [
'sphinxcontrib.plantuml',
]
you can use the following code to insert a figure into your document.
.. plantuml::
@startuml
Alice -> Bob: test
@enduml
sphinx-plantuml renders the figure in .svg
format, if you want .png
format, you can use :format:
argument.
.. plantuml::
:format: png
@startuml
Alice -> Bob: test
@enduml
if you want add a caption, you can use :caption:
argument.
.. plantuml::
:caption: this is caption
@startuml
Alice -> Bob: test
@enduml
sphinx-plantuml directive can load PlantUML code from file.
.. plantuml:: /the/path/of/file.uml
:caption: this is caption
sphinx-plantuml directive supports almost all arguments of sphinx builtin figure directive. for example, you can use :align:
argument to control the layout of the figure.
.. plantuml:: /the/path/of/file.uml
:caption: this is caption
:align: center