sphinxcontrib-plantuml

Sphinx "plantuml" extension

BSD 38 个版本
Yuya Nishihara <yuya@tcha.org>
安装
pip install sphinxcontrib-plantuml
poetry add sphinxcontrib-plantuml
pipenv install sphinxcontrib-plantuml
conda install sphinxcontrib-plantuml
描述

PlantUML for Sphinx

Installation

.. code-block::

pip install sphinxcontrib-plantuml

Usage

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

.. code-block:: python

extensions = [ 'sphinxcontrib.plantuml', ]

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

.. code-block:: python

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

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

.. code-block:: console

% cat < /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.

.. _PlantUML: http://plantuml.com/

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 :svg: generate .svg inside with .png inside as a fallback :svg_img: generate only .svg inside (browser support <svg_img_>) :svg_obj: generate only .svg inside (browser support <svg_obj_>) :none: do not generate any images (ignore uml directive)

When svg is inside it will always render full size, possibly bigger than the container. When svg is inside 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')

.. _svg_img: https://caniuse.com/svg-img .. _svg_obj: https://caniuse.com/svg

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

.. code-block::

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

.. code-block::

pytest
版本列表
0.31 2025-09-03
0.30 2024-05-22
0.29 2024-03-10
0.28 2024-02-21
0.27 2023-10-31
0.26 2023-08-26
0.25 2023-03-03
0.24.1 2022-11-18
0.24 2022-07-05
0.23 2022-02-28
0.22 2021-09-24
0.21 2021-05-11
0.20.1 2021-03-26
0.20 2021-03-21
0.19 2020-11-15
0.18.1 2020-09-13
0.18 2020-01-01
0.17.1 2019-09-02
0.17 2019-06-06
0.16.1 2019-05-30
0.16 2019-05-28
0.15 2019-04-13
0.14 2018-12-26
0.13 2018-12-02
0.12 2018-07-22
0.11 2018-03-27
0.10 2018-01-26
0.9 2018-01-13
0.8.2 2017-11-03
0.8.1 2016-05-10
0.8 2016-05-05
0.7 2016-02-27
0.6 2015-10-10
0.5 2014-10-05
0.4 2014-04-23
0.3 2012-03-31
0.2 2011-11-05
0.1 2011-03-26