Label
- class Label
Description
Label for the heading and declaration parts of this node or edge.
Inheritance:
Members defined in
Label(3 members)Methods
- decl(config: syside.PrinterConfig = ..., heritage: bool = True, feature_value: bool = True, escapes: syside.experimental.viz.Escapes = Escapes.none, style_callback: Callable[[str, syside.experimental.viz.SegmentStyle], tuple[str, str]] | None = None) str | None
Declaration part of this label.
This part includes anything not otherwise included by the
headingup to the body, and multiline declarations should be left aligned to match the formatted output.Certain declaration parts can be excluded, for example
# node == `attribute a : A = 2;` assert node.label.decl() == "a : A = 2" assert node.label.decl(heritage=False) == "a = 2" assert node.label.decl(feature_value=False) == "a : A"
while
style_callbackis invoked on text segments with non-plaintext style:assert node.label.decl(style_callback=lambda text, style: ("<p>", "</p>")) == "<p>a</p> : <p>A</p> = 2"
style_callbackmust return a pair of(prefix, suffix)which will then be used to surround the text segment. Thestyleargument to the callback is temporary and very likely to go out of scope as soon as the callback returns, do not use it outside. Furthermore, this implementation is very much subject to change.configwill be used to pretty-print the heading. Note that not all declaration parts are currently implemented.
- heading(config: syside.PrinterConfig = ...) str | None
Heading part of this label.
This part includes relevant keywords, modifiers, and metadata prefixes, all wrapped with guillemets. Headings should be centred.
Examples:
«part def»«abstract part def»«#Prefix part def»
configmay be used to pretty-print the heading.