question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

PlantUML !include preprocessor?

See original GitHub issue

I’m using lot of !include files in PlantUML diagrams to have clear sturcture and DRY.

== UML class diagram test with kroki
[plantuml, "diagram-classes", svg]
....
!include <src/style-presets.iuml>

class BlockProcessor
class DiagramBlock
class DitaaBlock
class PlantUmlBlock

BlockProcessor <|-- DiagramBlock
DiagramBlock <|-- DitaaBlock
DiagramBlock <|-- PlantUmlBlock
....

For local builds with plantuml.jar it works, but with remote server like PlantUML server or kroki it does not work. I understand that it is not wanted, because it will do preprocessing with knowlegde of PlantUML syntax and has to be updated etc.

Is there other solution to solve similar structural problems at client side?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:13 (10 by maintainers)

github_iconTop GitHub Comments

3reactions
anb0scommented, Apr 20, 2020

For using the Asciidoctor include derective i’ve to rework all the diagrams. It would be good to have a preprocessing task at client before sending it to the server. So at the end this would be good just to include the diagram files: e.g. presentation.adoc:

[plantuml, "diagram-classes", svg]
....
include::src/diagram-classes.puml[]
....

The diagram file itself includes other needed files.

src/diagram-classes.puml:

@startuml
!include <style-presets.iuml>

class BlockProcessor
class DiagramBlock
class DitaaBlock
class PlantUmlBlock

BlockProcessor <|-- DiagramBlock
DiagramBlock <|-- DitaaBlock
DiagramBlock <|-- PlantUmlBlock
@enduml

So the preprocessor should fetch all the files recursevly and avoid loading same files (include loop).

P.S.: similar was implemented in the vscode-plantuml plugin.

2reactions
Mogzttercommented, Jun 8, 2021

Sort of, the PlantUML preprocessor resolves !include directives in order to create a “standalone” diagram definition.

Unfortunately, it can’t resolve “complex” statements like %get_variable_value. Instead, the PlantUML preprocessor will try to read a file (using %get_variable_value("RELATIVE_INCLUDE")/C4.puml as path) on your local file system.

It’s tricky because it’s a preprocessor, so it cannot evaluate PlantUML syntax such as the if condition or the %get_variable_value function.

Do you send your diagrams to the public instance https://kroki.io or to a local instance?

If you want to use the built-in version of C4, I would recommend to use the following syntax:

!include <c4/C4_Context.puml>

In this case, the preprocessor will ignore the !include directive and Kroki server will resolve the !include directive using built-in C4 definition files.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Use the preprocessor - PlantUML
The PlantUML preprocessor provides features close to the C preprocessor. You can include files, define constant and macros. It's also possible to use ......
Read more >
Advanced Use — Ashley's PlantUML Doc 0.2.01 documentation
Preprocessor ¶ · can .zip a file and include it · You can use system environment variable or constant definition when using include....
Read more >
Plantuml - Foliant
PlantUML is a tool to generate diagrams from plain text. This preprocessor finds PlantUML diagrams definitions in the source and converts them into...
Read more >
Is it possible to run only the preprocessor? - PlantUML Q&A
Hi,. Iis it possible to just run the preprocessor and get back a new plantuml file without any macros, !include or !define etc...
Read more >
PlantUML: With preprocessor, how to check if key is present?
I think it's enough to check the value ( !if $domain_color.technical ): @startuml !$domain_color?={ "technical": "#gray" } '!$domain_color ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found