diff --git a/docs/configuration_file.md b/docs/configuration_file.md index 13b99677..ce309c8a 100644 --- a/docs/configuration_file.md +++ b/docs/configuration_file.md @@ -60,6 +60,68 @@ The following, are the `clang-uml` additional template functions: * `alias(string)` - returns a PlantUML alias of an C++ entity represented by string name * `comment(string)` - returns a comment of an C++ entity represented by string name +Templates allow complex postprocessing of the diagrams, for instance creation of customized PlantUML +notes in the diagrams from comments in the code. Below is an example of using the above commands to +generate notes in the PlantUML diagram from code comments (see also test case [t00050](./test_cases/t00050.md)): + +```yaml + plantuml: + after: + # Add a note left of the `A` class with the entire clas comment as content + - > + note left of {{ alias("A") }} + {{ comment("clanguml::t00050::A").formatted }} + end note + # Same as above + - > + note right of {{ element("clanguml::t00050::A").alias }} + {% set e=element("clanguml::t00050::A") %} {{ e.comment.formatted }} + end note + # Add a note left of class 'C' using trimmed text content from the class comment + - > + note left of {{ alias("C") }} #AABBCC + {{ trim(comment("clanguml::t00050::C").text) }} + end note + # For each element in the diagram (class, template, enum): + # - Add a note with \brief comment if exists + # - Add a note with \todo for each element which has it + # - Add a note with template parameter descriptions based on \tparam comment + - > + {# Render brief comments and todos, if any were written for an element #} + {% for e in diagram.elements %} + {% if existsIn(e, "comment") and existsIn(e.comment, "brief") %} + + note top of {{ e.alias }} {% if e.type == "class" %} #22AA22 {% else %} #2222AA {% endif %} + {% set c=e.comment %} {{ c.brief.0 }} + end note + + {% endif %} + {% if existsIn(e, "comment") and existsIn(e.comment, "todo") %} + {% set c=e.comment %} + {% for t in c.todo %} + note top of {{ e.alias }} #882222 + **TODO** + {{ t }} + end note + + {% endfor %} + + {% endif %} + {# Render template paramete if any #} + {% if existsIn(e, "comment") and existsIn(e.comment, "tparam") %} + {% set c=e.comment %} + + note top of {{ e.alias }} #AAAAFF + **Template parameters** + {% for tp in c.tparam %} + //{{ tp.name }}// {{ trim(tp.description) }} + {% endfor %} + end note + + {% endif %} + {% endfor %} +``` + ## Example complete config ```yaml