adrianvlupu / C4-Builder

This is a documentation builder. You feed it .md and .puml and it exports a site, pdf, or a markdown with navigation.
https://adrianvlupu.github.io/C4-Builder/
MIT License
563 stars 93 forks source link

Building PlantUML files that contain relative includes results in broken output diagrams #34

Closed pandasuit closed 2 years ago

pandasuit commented 3 years ago

Frequently I want to share common elements between multiple puml files or use my own local function/procedure library. Instead of copying the element into each file I just move that element into a shared file that both puml files include using a relative path.

For example I might have a shared library of puml in _shared.puml and include it in other puml files like this: !include _shared.puml

These relative paths work when using PlantUML preview IDE plugins or the plantuml JAR itself to create output image files.

When I build my project using C4-Builder the output diagrams contain an error message indicating it "cannot include _shared.puml".

If I switch to using an absolute path in the include it works however this is not an ideal solution when the C4 project is being worked on by multiple developers like ours are. We've been using a bit of a hack where the developers set their local project root directory in an environment variable and our puml files use that in their include statements.

The issue seems to be in the node-plantuml library used by C4-Builder. I tried using that library directly and I get the same error in output diagrams.

I was looking at how to fix this in node-plantuml and noticed that project hasn't been actively developed in a couple years but there is a more recent alternative called plantuml-pipe. That library does seem to handle relative includes properly in my testing so far. I haven't tried to change C4-Builder to use that library, I've just been using the library directly.

pandasuit commented 3 years ago

Seems the solution is a lot easier than I thought. PR for fix is here: https://github.com/adrianvlupu/C4-Builder/pull/42