Wiki source code of "plantuml" Macro
Last modified by Vincent Massol on 2026/10/21 19:17
Show last authors
| author | version | line-number | content |
|---|---|---|---|
| 1 | This macro draws a diagram from the textual definition written in its content, in the [[PlantUML language>>https://plantuml.com/]]. | ||
| 2 | |||
| 3 | The macro is listed in the "Content" category of the macros and also works inline, inside a paragraph. For a step-by-step use, see [[Add a Diagram to a Page>>doc:documentation.extensions.user.plantuml.add-diagram.WebHome]]. | ||
| 4 | |||
| 5 | == Parameters == | ||
| 6 | |||
| 7 | |=Parameter |=Default |=What it does | ||
| 8 | |##type## |##plantuml## |Diagram type used when the content does not start with an ##@start## line: the macro adds the start and end lines of that type. Ignored when the content has them. The values are listed in [[Diagram Types>>||anchor="HDiagramTypes"]]. | ||
| 9 | |##format## |##png##, unless the administrator set another default |Output format: ##png##, ##svg## or ##txt##, described in [[Output Formats>>||anchor="HOutputFormats"]]. | ||
| 10 | |##title## |None |Title added at the top of the diagram, unless the content already has a ##title## line. | ||
| 11 | |##server## |The server configured by the administrator |URL of the [[PlantUML server>>doc:documentation.extensions.admin.plantuml.WebHome]] that generates this diagram. An empty value uses the configured server. {{version since="2.5" product="PlantUML Macro"}}Accepted only when the page was last saved by a wiki administrator, and never in comments.{{/version}} | ||
| 12 | |||
| 13 | == Diagram Types == | ||
| 14 | |||
| 15 | |=##type## |=Diagram |=Start and end lines | ||
| 16 | |##plantuml## |UML diagram: sequence, use case, class, activity, component, state, deployment, timing and others |##@startuml## and ##@enduml## | ||
| 17 | |##ditaa## |Ditaa diagram drawn with ASCII characters |##@startditaa## and ##@endditaa## | ||
| 18 | |##dot## |GraphViz diagram. {{version since="2.5" product="PlantUML Macro"}}Only generated through a [[PlantUML server>>doc:documentation.extensions.admin.plantuml.WebHome]]: XWiki does not generate it itself with its default security profile.{{/version}} |##@startdot## and ##@enddot## | ||
| 19 | |##jcckit## |JCCKit chart |##@startjcckit## and ##@endjcckit## | ||
| 20 | |##salt## |Salt wireframe of a user interface |##@startsalt## and ##@endsalt## | ||
| 21 | |##mindmap## |Mind map |##@startmindmap## and ##@endmindmap## | ||
| 22 | |##regex## |Regular expression |##@startregex## and ##@endregex## | ||
| 23 | |##gantt## |Gantt chart |##@startgantt## and ##@endgantt## | ||
| 24 | |##chronology## |Chronology |##@startchronology## and ##@endchronology## | ||
| 25 | |##wbs## |Work breakdown structure |##@startwbs## and ##@endwbs## | ||
| 26 | |##ebnf## |Extended Backus-Naur form grammar |##@startebnf## and ##@endebnf## | ||
| 27 | |##json## |JSON data |##@startjson## and ##@endjson## | ||
| 28 | |##yaml## |YAML data |##@startyaml## and ##@endyaml## | ||
| 29 | |||
| 30 | == Output Formats == | ||
| 31 | |||
| 32 | |=##format## |=Displayed as |=Notes | ||
| 33 | |##png## |An image |The default. | ||
| 34 | |##svg## |An SVG drawing inserted in the page |Scales without blurring and keeps the links of the diagram clickable, as in the [[SVG example>>||anchor="HSVGDiagramwithLinks"]]. {{version since="2.5" product="PlantUML Macro"}}Elements not allowed in the page are removed from the drawing, and diagrams in comments are displayed as images instead.{{/version}} | ||
| 35 | |##txt## |ASCII art in a preformatted block |Available only for the diagram types that PlantUML can draw as text. | ||
| 36 | |||
| 37 | == Examples == | ||
| 38 | |||
| 39 | === Class Diagram === | ||
| 40 | |||
| 41 | {{code language="none"}} | ||
| 42 | {{plantuml}} | ||
| 43 | @startuml | ||
| 44 | package "Classic Collections" #DDDDDD { | ||
| 45 | Object <|-- ArrayList | ||
| 46 | } | ||
| 47 | |||
| 48 | package net.sourceforge.plantuml { | ||
| 49 | Object <|-- Demo1 | ||
| 50 | Demo1 *- Demo2 | ||
| 51 | } | ||
| 52 | @enduml | ||
| 53 | {{/plantuml}} | ||
| 54 | {{/code}} | ||
| 55 | |||
| 56 | {{image reference="class-diagram.png" size="large" alt="Class diagram with an Object class extended by ArrayList in a Classic Collections package and by Demo1, composed of Demo2, in a net.sourceforge.plantuml package"/}} | ||
| 57 | |||
| 58 | === Ditaa Diagram === | ||
| 59 | |||
| 60 | {{code language="none"}} | ||
| 61 | {{plantuml}} | ||
| 62 | @startditaa | ||
| 63 | Web Browser JEE Server | ||
| 64 | /--------\ +---------+ Database | ||
| 65 | +--------+ |c789 | +---+ | ||
| 66 | |c1FF |<------->| XWIKI |<-=-->|{s}| | ||
| 67 | | Wiki | text | | +---+ | ||
| 68 | | page | +---------+ | ||
| 69 | | with | |c789 | +---+ | ||
| 70 | |diagrams|<------->|PlantUML |<-=-->|{o}| | ||
| 71 | | | image | Server| +---+ | ||
| 72 | \--------/ +---------+ Graphviz | ||
| 73 | @endditaa | ||
| 74 | {{/plantuml}} | ||
| 75 | {{/code}} | ||
| 76 | |||
| 77 | {{image reference="ditaa-diagram.png" size="large" alt="Ditaa diagram of a web browser exchanging text and images with XWiki and a PlantUML server, which use a database and Graphviz"/}} | ||
| 78 | |||
| 79 | === SVG Diagram with Links === | ||
| 80 | |||
| 81 | {{code language="none"}} | ||
| 82 | {{plantuml format="svg"}} | ||
| 83 | @startuml | ||
| 84 | title [[https://github.com/xwiki/xwiki-rendering XWiki Rendering]] General Architecture | ||
| 85 | |||
| 86 | file "Input Syntax" as Input | ||
| 87 | component Parser [ | ||
| 88 | [[https://github.com/xwiki/xwiki-rendering/blob/master/xwiki-rendering-api/src/main/java/org/xwiki/rendering/parser/Parser.java Parser]] | ||
| 89 | ] | ||
| 90 | component Transformations [ | ||
| 91 | [[https://github.com/xwiki/xwiki-rendering/blob/master/xwiki-rendering-api/src/main/java/org/xwiki/rendering/transformation/Transformation.java Transformations]] | ||
| 92 | ] | ||
| 93 | component Renderer [ | ||
| 94 | [[https://github.com/xwiki/xwiki-rendering/blob/master/xwiki-rendering-api/src/main/java/org/xwiki/rendering/renderer/Renderer.java Renderer]] | ||
| 95 | ] | ||
| 96 | file Output | ||
| 97 | |||
| 98 | Input -> Parser | ||
| 99 | Parser -> Transformations : XDOM | ||
| 100 | Transformations -> Renderer : XDOM | ||
| 101 | Renderer -> Output | ||
| 102 | @enduml | ||
| 103 | {{/plantuml}} | ||
| 104 | {{/code}} | ||
| 105 | |||
| 106 | {{image reference="svg-diagram.png" size="extra" alt="SVG component diagram of the XWiki Rendering architecture whose title and Parser, Transformations and Renderer components are links"/}} |