Skip to main content

PlantUML for Sphinx

Installation

pip install sphinxcontrib-plantuml

Usage

Add sphinxcontrib.plantuml to your extensions list in your conf.py:

extensions = [
    'sphinxcontrib.plantuml',
]

You may also need to specify the plantuml command in your conf.py:

plantuml = 'java -jar /path/to/plantuml.jar'

Instead, you can install a wrapper script in your PATH:

% cat <<EOT > /usr/local/bin/plantuml
#!/bin/sh -e
java -jar /path/to/plantuml.jar "$@"
EOT
% chmod +x /usr/local/bin/plantuml

Then, write PlantUML text under the .. uml:: (or .. plantuml::) directive:

.. uml::

   Alice -> Bob: Hi!
   Alice <- Bob: How are you?

or specify path to an external PlantUML file:

.. uml:: external.uml

You can specify height, width, scale and align:

.. uml::
   :scale: 50 %
   :align: center

   Foo <|-- Bar

You can also specify a caption:

.. uml::
   :caption: Caption with **bold** and *italic*
   :width: 50mm

   Foo <|-- Bar

For details, please see PlantUML documentation.

Configuration

plantuml

Path to plantuml executable. (default: ‘plantuml’)

plantuml_output_format

Type of output image for HTML renderer. (default: ‘png’)

png:

generate only .png inside </img>

svg:

generate .svg inside <object/> with .png inside </img> as a fallback

svg_img:

generate only .svg inside <img/> (browser support)

svg_obj:

generate only .svg inside <object/> (browser support)

none:

do not generate any images (ignore uml directive)

When svg is inside <object/> it will always render full size, possibly bigger than the container. When svg is inside <img/> it will respect container size and scale if necessary.

plantuml_latex_output_format

Type of output image for LaTeX renderer. (default: ‘png’)

svg_pdf:

generate .svg and convert it to .pdf (requires registered ImageConverter)

eps_pdf:

generate .eps and convert it to .pdf (requires epstopdf)

pdf:

use svg_pdf if available, fallback to eps_pdf

eps:

generate .eps (not supported by pdflatex)

png:

generate .png

tikz:

generate .latex in the TikZ format

none:

do not generate any images (ignore uml directive)

Because embedded png looks pretty bad, it is recommended to choose svg_pdf.

An example for the registered ImageConverter would be sphinxcontrib.inkscapeconverter from sphinxcontrib-svg2pdfconverter. The first detected converter that supports .svg to .pdf is used.

plantuml_epstopdf

Path to epstopdf executable. (default: ‘epstopdf’)

plantuml_syntax_error_image

Should plantuml generate images with render errors. (default: False)

plantuml_cache_path

Directory where image cache is stored. (default: ‘_plantuml’)

plantuml_batch_size

(EXPERIMENTAL) Run plantuml command per the specified number of images. (default: 1)

If enabled, plantuml documents will be first written to the cache directory, and rendered in batches. This eliminates bootstrapping overhead of Java runtime and allows plantuml to leverage multiple CPU cores.

To enable batch rendering, set the size to 100-1000.

Developing

Install the python test dependencies with

pip install sphinxcontrib-plantuml[test]

In addition the following non-python dependencies are required in order to run the tests:

  • latexmk

  • plantuml

  • texlive

  • texlive-font-utils

  • texlive-latex-extra

The tests can be executed using pytest

pytest

Release files for sphinxcontrib-plantuml 0.31

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sphinxcontrib-plantuml 0.31
File Size Uploaded
sphinxcontrib_plantuml-0.31.tar.gz 15.7 kB Details

Release files / sphinxcontrib_plantuml-0.31.tar.gz

Download URL sphinxcontrib_plantuml-0.31.tar.gz
Size 15.7 kB
Tags Source
SHA-256 checksum
How to use checksums
fd74752f8ea070e641c3f8a402fccfa1d4a4056e0967b56033d2a76282d9f956
BLAKE2b-256 checksum
How to use checksums
088ff26dd61b92176c4cba6b7898ca2875e7dfc29263d8e1b3b63d6acf81434f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release history Release notifications | RSS feed

This release

0.31 This release

1 release file

0.30

1 release file

0.29

1 release file

0.28

1 release file

0.27

1 release file

0.26

1 release file

0.25

1 release file

0.24.1

1 release file

0.24

1 release file

0.23

1 release file

0.22

1 release file

0.21

1 release file

0.20.1

1 release file

0.20

1 release file

0.19

1 release file

0.18.1

1 release file

0.18

1 release file

0.17.1

1 release file

0.17

1 release file

0.16.1

1 release file

0.16

1 release file

0.15

1 release file

0.14

1 release file

0.13

1 release file

0.12

1 release file

0.11

1 release file

0.10

1 release file

0.9

1 release file

0.8.2

1 release file

0.8.1

1 release file

0.8

1 release file

0.7

1 release file

0.6

1 release file

0.5

1 release file

0.4

1 release file

0.3

1 release file

0.2

1 release file

0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page