functiongetClassDiagram
Information
Returns a UML class diagram of className, as PlantUML
text, as Mermaid text, which GitHub and GitLab show as a
diagram in a mermaid code block, or as a draw.io
(diagrams.net) file that can be edited and rearranged.
The diagram has the class, the classes it extends, directly or not, and the classes it uses
up to depth levels: the types of its components, and the classes replaceable
classes default to, are constrained by or are redeclared as. With depth = 0 it only
has the class and its base classes. Class extends (redeclare model extends) and
redeclared classes declared in a class in the diagram are also in it, together with the classes
they replace. The names are looked up like in getDefUseChains, without instantiating
anything, so it also works for packages and partial classes.
Every class is shown with its full name, how it's declared as stereotype
(e.g. «replaceable package» or «redeclare function extends»)
and partial classes as abstract, with the components and short class definitions declared in it and
the replaceable classes declared in it that aren't in the diagram. extends and class
extends are generalizations, labelled with their modifiers, components of a class in the diagram
are compositions, labelled with their names and dimensions, and short class definitions, constraining
classes and redeclares in modifiers are dependencies, labelled with what declares them, and a
redeclared class that doesn't extend the class it replaces depends on it, labelled
redeclares. Classes declared in a class are nested in it; Mermaid has no nesting, so
there they are linked to it, labelled nested.
In the draw.io file every class links to modelica:// and its name, and every line
in the box of a class links to the line in the file of the element it shows, e.g.
modelica://P.M?lineNumber=12, and for a component also to its name, e.g.
modelica://P.M?lineNumber=12&element=c.
The classes in exclude and in the packages in exclude are left out,
except className itself.
With showModifiers = false the modifiers and bindings aren't shown.
Inputs
| Type | Name | Default | Description |
|---|---|---|---|
| TypeName | className | ||
| String | fileName | "" | The file to write the diagram to, if not empty. |
| String | format | "plantuml" | plantuml, mermaid or drawio. |
| Integer | depth | 1 | How many levels of used classes to include. |
| String[:] | exclude | {"Modelica.Icons"} | Classes and packages to leave out. |
| Boolean | showModifiers | true |
Outputs
| Type | Name | Default | Description |
|---|---|---|---|
| String | diagram | The diagram, or the file name if it was written to a file. |