In an attempt to improve PlantUML documentation...
Wiki Toc Recent changes View page history Add new chapter Reorder page Raw
![]() |
![]() |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Preprocessing-v2 (old)Some minor preprocessing capabilities are included in PlantUML, and available for all diagrams. Those functionalities are very similar to the C language preprocessor, except that the special character# has been changed to the exclamation mark ! .
The actual preprocessor will be replaced by a new one, with new functionalities. This new preprocessor is 95% compatible with the current one.
Right now, you have to switch to the new preprocessor using a special directive !preprocessorV2 with last offical release (that is V1.2019.5). Or you can directly use the last beta where the V2 preprocessor is enabled by default.
This way, you can check that your diagram are still working with the future version.
In some future, the old preprocessor will be removed.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Migration notesThe new preprocessor will be enable by default in the incoming versions of PlantUML. Even if some legacy feature are still supported with the new preprocessor, you should not use them any more (they might be finally removed in some long term future).
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Variable definitionAlthough this is not mandatory, we highly suggest that variable name start with a$ .
There are two kind of data:
global keyword when defining a variable.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Conditions
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Void function
Variables defined in functions are local. It means that the variable is destroyed when the function is exited. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Return functionA return function does not output any text. It just define a function that you can call:
It is possible to shorten simple function definition in one line:
As in void function, variable are local by default (they are destroyed when the function is exited). However, you can access to global variables from function. However, you can use the local keyword to create a local variable if ever a global variable exists with the same name.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Default argument valueIn both return and void function, you can define default value for argument.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Unquoted functionBy default, you have to put quotes when you call a function. It is possible to use theunquoted keyword to indicate that a function does not require quotes for its arguments.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Including files or URLUse the!include directive to include file in your diagram. Using URL, you can also include file from Internet/Intranet.
Imagine you have the very same class that appears in many
diagrams. Instead of duplicating the description of this class, you can
define a file that contains the description.
File List.iuml
The file List.iuml can be included in many diagrams, and
any modification in this file will change all diagrams that include it.
You can also put several @startuml/@enduml text block in an included file and then specify which block
you want to include adding !0 where 0 is the block number. The !0 notation denotes the first diagram.
For example, if you use !include foo.txt!1 , the second @startuml/@enduml block
within foo.txt will be included.
You can also put an id to some @startuml/@enduml text block in an included file using
@startuml(id=MY_OWN_ID) syntax and then include the block adding !MY_OWN_ID when including the file,
so using something like !include foo.txt!MY_OWN_ID .
By default, a file can only be included once. You can use !include_many instead of !include if you want to include some file several times. Note that there is also a !include_once directive that raises an error if a file is included several times.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Including SubpartYou can also use!startsub NAME and !endsub to indicate sections of text to include from other files using !includesub . For example:
file1.puml:
file1.puml would be rendered exactly as if it were:
However, this would also allow you to have another file2.puml like this: file2.puml
This file would be rendered exactly as if:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Builtin functionsSome functions are defined by default. Their name starts by%
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
LoggingYou can use!log to add some log output when generating the diagram. This has no impact at all on the diagram itself. However, those logs are printed in the command line's output stream. This could be useful for debug purpose.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Memory dumpYou can use!memory_dump to dump the full content of the memory when generating the diagram. An optional string can be put after !memory_dump . This has no impact at all on the diagram itself. This could be useful for debug purpose.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
AssertionYou can put assertion in your diagram.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Building custom libraryIt's possible to package a set of included files into a single .zip or .jar archive. This single zip/jar can then be imported into your diagram using!import directive.
Once the library has been imported, you can !include file from this single zip/jar.
Example:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Search pathYou can specify the java propertyplantuml.include.path in the command line.
For example:
Note the this -D option has to put before the -jar option. -D options after the -jar option will be used to define constants within plantuml preprocessor. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Argument concatenationIt is possible to append text to a macro argument using the## syntax.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Dynamic function invocationYou can dynamically invoke a void function using the special%invoke_void_func() void function.
This function takes as first argument the name of the actual void function to be called. The following argument are copied to the called function.
For example, you can have:
For return functions, you can use the corresponding special function %call_user_func() :
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||