edgegraph.output.plantuml

edgegraph.output.plantuml#

Create PlantUML sourcecode for a graph, and generate images from it.

This module mostly does not require PlantUML installed to operate. It only needs PlantUML installed to actually generate the images – for only sourcecode generation, it does not need to be installed.

See also

PlantUML’s homepage: https://plantuml.com/

The intended usage pattern is something like:

from edgegraph.builder import randgraph
from edgegraph.output import plantuml

graph = randgraph.randgraph()

# don't need PlantUML installed for this!
#
# puml_src is just a big long string.  you can print it out, write it to a
# file, do whatever you want with it if you don't want to render it
# immediately
puml_src = plantuml.render_to_plantuml_src(graph,
    plantuml.PLANTUML_RENDER_OPTIONS)

if plantuml.is_plantuml_installed():

    # after this, my_graph.png will exist in current working directory
    plantuml.render_to_image(puml_src, "my_graph.png")

else:
    print("Sorry, couldn't render!  Please ensure PlantUML is installed.")

Of course, much customization is available, primarily via the second argument to render_to_plantuml_src(). PLANTUML_RENDER_OPTIONS should have some pretty sensible defaults, and would be a good place to start reading about customization.

If your installation of PlantUML needs non-standard invocations, that is handled in three possible ways:

  1. If you need to customize the arguments to PlantUML, use the PLANTUML_INVOKE_ARGS list. This affects all invocations to PlantUML that this module will make.

  2. If you need to customize environs available to PlantUML, use the PLANTUML_INVOKE_ENV dict. This affects all invocations to PlantUML that this module will make.

  3. If you need to change the location / execution of PlantUML, see the plantuml argument to is_plantuml_installed() and render_to_image().

Module Attributes

PLANTUML_RENDER_OPTIONS

Default options for PlantUML rendering.

PLANTUML_INVOKE_ARGS

List of arguments to always invoke plantuml with.

PLANTUML_INVOKE_ENV

Environment variable overrides to invoke plantuml with.

Functions

is_plantuml_installed([plantuml])

Checks if PlantUML is installed and usable on this system.

render_to_image(src, out_file[, plantuml])

Accept string PlantUML source, and create an image.

render_to_plantuml_src(uni, options)

Render a universe to PlantUML source.