Is it possible to add custom metadata to a PlantUML source file?

0 votes
asked May 8, 2021 in To be sorted by Rob Bell

Hi,

I'm writing a Git hook to generate PlantUML diagrams as part of the pre-commit stage to Git. The plan is to have the hook scan the repository for *.plantuml files, generate PNGs or SVGs then include them in the commit. I'd like to be able to add some metadata to the source files to let the user set the destination for the generated files, e.g.:

@startuml
[Destination=./output/class-diagrams/]
Bob->Alice : hello
@enduml


I've thought about implementing it using some custom syntax in a comment, but thought I'd check to see if there is any standard way to do this with PlantUML diagrams.

1 Answer

0 votes
answered May 9, 2021 by The-Lu (43,700 points)

Hello R.,

You can just use a comment.. It will be on the metadata of the diagram... as:

@startuml
'Destination=./output/class-diagrams/
Bob->Alice : hello
@enduml

or:

@startuml
/'
Destination=./output/class-diagrams/
'/
Bob->Alice : hello
@enduml

See also:

If that can help,
Regards,
Th.

commented May 10, 2021 by plantuml (273,580 points)

You can also use the !pragma directive, as long as it does not clash with some existing property :

@startuml
!pragma Destination ./output/class-diagrams/
Bob->Alice : hello
@enduml
commented May 10, 2021 by The-Lu (43,700 points)

Hello all,

Even at worst, you can put on a preprocessing variable (and adding double quotes around value), as long as it does not clash with some existing variable...:

@startuml
!Destination="./output/class-diagrams/"
Bob->Alice : hello
@enduml

Regards,
Th.

...