linkahead.utils.plantuml module

Utilities for work with PlantUML.

PlantUML (http://plantuml.com) is a converter from a simple descriptive language to graphviz diagrams.

To convert the output, you can write it into FILENAME.pu and then convert it with:

plantuml FILENAME.pu -> FILENAME.png

class linkahead.utils.plantuml.Grouped(name, parents)

Bases: object

get_parents()
linkahead.utils.plantuml.get_description(description_str)

Extract and format a description string from a record type or property.

Parameters:

description_str (str) – The description string that is going to be formatted.

Returns:

The reformatted description ending in a line break.

Return type:

str

linkahead.utils.plantuml.recordtypes_to_plantuml_string(iterable, add_properties: bool = True, add_recordtypes: bool = True, add_legend: bool = True, no_shadow: bool = False, style: str = 'default')

Converts RecordTypes into a string for PlantUML.

This function obtains an iterable and returns a string which can be input into PlantUML for a representation of all RecordTypes in the iterable.

Current options for style

“default” - Standard rectangles with uml class circle and methods section “salexan” - Round rectangles, hide circle and methods section

Current limitations

  • It is inherently hard to detect if an element should be rendered as a class/RecordType or not. Currently it is rendered if either the “type” attribute is None or type(element) == RecordType.

  • Inheritance of Properties is not rendered nicely at the moment.

param iterable:

The objects to be rendered with plantuml.

type iterable:

iterable of linkahead.Entity

param no_shadow:

If true, tell plantuml to use a skin without blurred shadows.

type no_shadow:

bool, optional

returns:

out – The plantuml string for the given container.

rtype:

str

linkahead.utils.plantuml.retrieve_substructure(start_record_types, depth, result_id_set=None, result_container=None, cleanup=True)

Recursively retrieves LinkAhead record types and properties, starting from given initial types up to a specific depth.

Parameters:
  • start_record_types (Iterable[db.Entity]) – Iterable with the entities to be displayed. Starting from these entities more entities will be retrieved.

  • depth (int) – The maximum depth up to which to retriev sub entities.

  • result_id_set (set[int]) – Used by recursion. Filled with already visited ids.

  • result_container (db.Container) – Used by recursion. Filled with already visited entities.

  • cleanup (bool) – Used by recursion. If True return the resulting result_container. Don’t return anything otherwise.

Returns:

A container containing all the retrieved entites or None if cleanup is False.

Return type:

db.Container

linkahead.utils.plantuml.to_graphics(recordtypes: List[Entity], filename: str, output_dirname: str | None = None, formats: List[str] = ['tsvg'], silent: bool = True, add_properties: bool = True, add_recordtypes: bool = True, add_legend: bool = True, no_shadow: bool = False, style: str = 'default')

Calls recordtypes_to_plantuml_string(), saves result to file and creates an svg image

plantuml needs to be installed.

Parameters:
  • recordtypes (Iterable[db.Entity]) – Iterable with the entities to be displayed.

  • filename (str) – filename of the image without the extension(e.g. data_structure; also without the preceeding path. data_structure.pu and data_structure.svg will be created.)

  • output_dirname (str) – the destination directory for the resulting images as defined by the “-o” option by plantuml default is to use current working dir

  • formats (List[str]) – list of target formats as defined by the -t”…” options by plantuml, e.g. “tsvg”

  • silent (bool) – Don’t output messages.

  • no_shadow (bool, optional) – If true, tell plantuml to use a skin without blurred shadows.