docsy icon indicating copy to clipboard operation
docsy copied to clipboard

Let the PlantUML code block embed the generated image instead of the PlantUML server request

Open adlerzei opened this issue 9 months ago • 1 comments

The PlantUML code block does not embed the generated image when building the page. Instead, the image is regenerated each time the page is fetched. This has two disadvantages:

Firstly, there is a lot of unnecessary traffic.

But more importantly, the PlantUML server may not be accessible from anywhere on the web. In our case, our PlantUML server is hosted on the corporate network. When our page is built, it can be accessed. But from anywhere outside our network, the PlantUML diagrams will not load.

It would be nice if there was an option to embed the generated image when building the page, rather than having the image generated when the page is visited.

adlerzei avatar Mar 14 '25 11:03 adlerzei

I had a similar issue of not wanting to call out to an external server for the puml conversion. The approach I took is to have the puml in separate .puml files. This is possibly better when you have large diagrams or want to open the .puml file in an IDE that can preview the puml.

I have a script to convert all the .puml files (that have a different sha1 since last run) into a .puml.svg file. The svgs are then just included in the docs as standard svg images. This script can be run before serving the site locally and as part of the CI build pipeline.

The script is not doing anything clever, but is here in case it is useful: https://github.com/gchq/stroom-docs/blob/master/container_build/docker_puml/convert_puml_files.sh

However, I agree that for inline puml code blocks, the conversion should ideally happen at build time.

at055612 avatar Mar 20 '25 10:03 at055612