trlcdoc.plantuml

Provide the PlantUML jar, replacing the get_plantuml.sh/.bat scripts.

Attributes

LOG

DEFAULT_VERSION

DOWNLOAD_URL

JAVA_HEADLESS

PICOWEB_HOST

PICOWEB_START_TIMEOUT

PICOWEB_POLL_INTERVAL

PICOWEB_STOP_TIMEOUT

PICOWEB_PROBE_DIAGRAM

NO_PROXY_NAMES

PICOWEB_ENV_NAMES

Classes

PicowebServer

The running PlantUML picoweb server and what to restore when it stops.

Functions

provide_plantuml(cfg) → pathlib.Path | str

Locate or download plantuml.jar and export it in the PLANTUML environment variable.

start_picoweb(cfg, jar) → str | None

Start the PlantUML jar as local picoweb server and export its URL in the PLANTUML environment variable.

stop_picoweb() → None

Stop the picoweb server, if one runs, and restore the environment from before its start.

java_headless_env() → dict[str, str]

Get the environment that makes Java run PlantUML headless in the converters.

Module Contents

trlcdoc.plantuml.LOG
trlcdoc.plantuml.DEFAULT_VERSION = '1.2024.8'
trlcdoc.plantuml.DOWNLOAD_URL = 'https://github.com/plantuml/plantuml/releases/download/v{version}/plantuml-{version}.jar'
trlcdoc.plantuml.JAVA_HEADLESS = '-Djava.awt.headless=true'
trlcdoc.plantuml.PICOWEB_HOST = '127.0.0.1'
trlcdoc.plantuml.PICOWEB_START_TIMEOUT = 30.0
trlcdoc.plantuml.PICOWEB_POLL_INTERVAL = 0.1
trlcdoc.plantuml.PICOWEB_STOP_TIMEOUT = 5.0
trlcdoc.plantuml.PICOWEB_PROBE_DIAGRAM = Multiline-String
Show Value
"""@startuml
A -> B
@enduml
"""
trlcdoc.plantuml.NO_PROXY_NAMES = ('NO_PROXY', 'no_proxy')
trlcdoc.plantuml.PICOWEB_ENV_NAMES = ('PLANTUML', 'NO_PROXY', 'no_proxy')
class trlcdoc.plantuml.PicowebServer[source]

The running PlantUML picoweb server and what to restore when it stops.

process: subprocess.Popen

The Java process of the server.

url: str

Server URL for the PLANTUML environment variable.

saved_env: dict[str, str | None]

Values of PICOWEB_ENV_NAMES before the server started, None if unset.

saved_sigterm: Any = None

The SIGTERM handler before the server started, None if it was not replaced.

trlcdoc.plantuml.provide_plantuml(cfg: trlcdoc.config.Config) → pathlib.Path | str[source]

Locate or download plantuml.jar and export it in the PLANTUML environment variable.

The PLANTUML environment variable, a jar or a PlantUML server URL, has precedence over the configured jar, which has precedence over a download of the configured version. A jar needs Java and Graphviz, which are checked before anything is downloaded.

With plantuml.picoweb (default), a jar is started once as local picoweb server, and its URL is exported instead of the jar. If the server doesn’t start, the jar is exported.

Parameters:

cfg (Config) – Project configuration.

Returns:

The plantuml.jar file, or the PlantUML server URL.

Return type:

Path | str

Raises:

TrlcdocError – If the jar is missing and cannot be downloaded, or Java or Graphviz is missing.

trlcdoc.plantuml.start_picoweb(cfg: trlcdoc.config.Config, jar: pathlib.Path) → str | None[source]

Start the PlantUML jar as local picoweb server and export its URL in the PLANTUML environment variable.

The server runs until stop_picoweb(), which trlcdoc calls when it finishes, and at the latest when Python exits. If the server doesn’t render a diagram within PICOWEB_START_TIMEOUT seconds, it is stopped and a warning is printed: the jar renders each diagram instead.

Parameters:
  • cfg (Config) – Project configuration.

  • jar (Path) – The plantuml.jar file.

Returns:

The server URL, or None if the server is not available.

Return type:

str | None

trlcdoc.plantuml.stop_picoweb() → None[source]

Stop the picoweb server, if one runs, and restore the environment from before its start.

The server gets PICOWEB_STOP_TIMEOUT seconds to stop, then it is killed.

trlcdoc.plantuml.java_headless_env() → dict[str, str][source]

Get the environment that makes Java run PlantUML headless in the converters.

pyTRLCConverter starts PlantUML with the headless option only on Linux. Windows needs none, but on macOS each diagram would start the graphical user interface support of Java (Dock icon). Java reads additional options from JAVA_TOOL_OPTIONS. It reports them on stderr, which pyTRLCConverter logs as error, so they are only set on macOS.

see also: https://github.com/NewTec-GmbH/pyTRLCConverter/issues/180

Returns:

Additional environment variables for the converters, empty except on macOS.

Return type:

dict[str, str]