generate-plantuml-action
generate-plantuml-action copied to clipboard
Unable to generate .svgs when PlantUML uses !include for files in parent directory.
I have two files. (Pseudo-representation below, scrubbed for privacy)
One is a large file in a parent directory called definitions.puml
The other file is in a subfolder called architecture.pu
They are arranged like so.
src/definitions.puml
'' DATABASE DEF
!define db_name Name of database
!define db_tech technology: technology desc
!define db_desc Holds data for system.
' ... etc
src/level1/architecture.pu
@startuml
!include ../definitions.puml
' rest of content below
@enduml
The outcome is a generated SVG that is "undefined" and has no content.
Github preview reads: Sorry, this file is invalid so it cannot be displayed.
Edit:
I have even tried this format !include %dirpath/../definitions.puml
No luck.
Looking through the code. I did not realize this action is relying on an external API...
https://github.com/grassedge/generate-plantuml-action/blob/fd4ec36c98431530c0ff2cb9d5c3ace16a1d33c1/src/main.ts#L14
As you see, this action uses PlantUML Server. So it is difficult to refer other files, such as !include
expression. 😞
I think there are two approaches.
- Parse
!include
expression in JavaScript code, and join included files and post it to PlantUML server. - Rewrite to use container runner and run PlantUML itself on this action.
Approach 1 looks bad because it costs much to be maintained. So I will try to do approach 2 when I have a enough time.
For my solution, I ended up writing a native implementation and including the plantuml.jar
within my repo.
@grassedge https://gist.github.com/thedmeyer/8b50362ae71ecbadabb17f8683c70ece