Reputation: 124
Given the following rst:
.. uml:: ClassDiagram.puml
:caption: ClassDiagram
conf.py contains only the extension:
extensions = ["sphinxcontrib.plantuml"]
With Sphinx, I build an html page. The included uml diagram is as follows:
This image is generated with the input as the filename, instead of the contents of the filename.
What am I doing wrong?
I cannot find any existing questions about this issue.
Python version: 3.12.3
Sphinx version: 7.2.6
Upvotes: 0
Views: 140
Reputation: 866
I think you're saying that the UML diagram renders the literal text "ClassDiagram.puml", rather than the content in a file by that name. I can't reproduce that problem.
Your minimal reproducible example doesn't show the Sphinx build log, or the content of file ClassDiagram.puml
.
PlantUML is liberal with what it accepts so you can omit a lot - like the @startuml
@enduml
tags - and it will still parse/render OK. Whether I pass an implicit filename, or an explicit UML script, the Sphinx extension seems to distinguish the arguments properly. So...
.. uml::
:caption: MyExample
ClassDiagram.puml
will render just fine, as is (live server demo).
.. uml:: ClassDiagram.puml
:caption: MyExample
will render the content of that file if the file exists, or fail WARNING: PlantUML file "ClassDiagram.puml" cannot be read: [Errno 2] No such file or directory
if the file doesn't exist.
.. uml:: ClassDiagram.puml
:caption: MyExample
a dummy
UML script
will fail WARNING: uml directive cannot have both content and a filename argument [docutils]
.
.. uml::
:caption: MyExample
a dummy
UML script
will fail /home/mc1/Desktop/temp/index.rst:35: WARNING: error while running plantuml
(the content got passed to PlantUML, but was rejected as invalid syntax).
Next steps...
ClassDiagram.puml
actually exist?.
# My environment
$ python --version
Python 3.12.3
$ sphinx-build --version
sphinx-build 8.1.3
$ find ~/venv/lib/python3.12/site-packages -iname "*plant*"
sphinxcontrib_plantuml-0.30
Upvotes: 0