plantweb.render

Plantweb main rendering module.

Functions

  • render_file(): Render given PlantUML, Graphviz or DITAA file.
  • render(): Render given PlantUML, Graphviz or DITAA content.
  • render_cached(): Render given content in the PlantUML server or fetch it from cache.
  • determine_engine(): Determine the engine used in the given content.
plantweb.render.render_file(infile, outfile=None, renderopts=None, cacheopts=None)

Render given PlantUML, Graphviz or DITAA file.

Parameters:
  • infile (str) – Path to source file to render.
  • outfile (str) – Path to output file. If None, the filename will be auto-determined and saved to the current working directory.
  • renderopts (dict) – Rendering options (engine, format and server) as in render().
  • cacheopts (dict) – Caching options (use_cache and cache_dir) as in render().
Returns:

Path to output file.

Return type:

str

plantweb.render.render(content, engine=None, format=None, server=None, cacheopts=None)

Render given PlantUML, Graphviz or DITAA content.

Parameters:
  • content (str) – Content to render.
  • engine (str) – Engine to use to render the content. One of 'plantuml', 'graphviz' or 'ditaa'. If None, the engine will be auto-determined by looking into the content for the @startxxxx tags, and if unable to be auto-determined the default engine will be used.
  • format (str) – Format of the rendered content. Raster png or vector svg. Please note that engine ditaa can only render to png. If None, the default formatwill always be selected unless the engine doesn’t supports it.
  • server (str) – URL to PlantUML server. This will passed as is to render_cached(). If None the default server URL will be used.
Returns:

A tuple of (output, format, engine, sha) with the bytes of the rendered output, a string with the name of the output format, a string with the name of the engine used or detected and a string of the sha256 for identifying the cache file.

Return type:

tuple

plantweb.render.render_cached(server, format, content, use_cache=None, cache_dir=None)

Render given content in the PlantUML server or fetch it from cache.

Parameters:
  • server (str) – URL to PlantUML server.
  • format (str) – File format to render the content. One of the supported by the PlantUML server (svg or png).
  • content (str) – Content to render with mandatory @startxxx tags.
  • use_cache (bool) – Use local cache to avoid requesting the server for already rendered diagrams. If None, the default value will be used.
  • cache_dir (str) – Directory to store the cached diagrams. If None the default value will be used.
Returns:

A tuple of (content, sha) with the bytes of the rendered content and a sha256 hash string identifying the content.

Return type:

tuple

plantweb.render.determine_engine(content)

Determine the engine used in the given content.

The engine is determined by the @startXXX used at the beginning of the file. Possible values are:

@startuml --> plantuml
@startdot --> graphviz
@startditaa --> ditaa
Parameters:content (str) – Content to analyze.
Returns:The name of the engine found, or None.
Return type:str

Variables

plantweb.render.WRAP_STR

Map between the name of the engine and the wrap string used in the @startXXX directive.

{'ditaa': 'ditaa', 'graphviz': 'dot', 'plantuml': 'uml'}