generate-plantuml-action icon indicating copy to clipboard operation
generate-plantuml-action copied to clipboard

Unable to generate .svgs when PlantUML uses !include for files in parent directory.

Open thedmeyer opened this issue 5 years ago • 5 comments

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.

thedmeyer avatar Jan 29 '20 21:01 thedmeyer

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

thedmeyer avatar Jan 29 '20 21:01 thedmeyer

As you see, this action uses PlantUML Server. So it is difficult to refer other files, such as !include expression. 😞

grassedge avatar Feb 03 '20 01:02 grassedge

I think there are two approaches.

  1. Parse !include expression in JavaScript code, and join included files and post it to PlantUML server.
  2. 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.

grassedge avatar Feb 05 '20 15:02 grassedge

For my solution, I ended up writing a native implementation and including the plantuml.jar within my repo.

thedmeyer avatar Feb 05 '20 16:02 thedmeyer

@grassedge https://gist.github.com/thedmeyer/8b50362ae71ecbadabb17f8683c70ece

thedmeyer avatar Feb 05 '20 19:02 thedmeyer