grassedge / generate-plantuml-action

Generate uml diagrams with Plantuml Server and push them to your repository.
MIT License
107 stars 169 forks source link

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

Open thedmeyer opened 4 years ago

thedmeyer commented 4 years ago

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 commented 4 years ago

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

grassedge commented 4 years ago

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

grassedge commented 4 years ago

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.

thedmeyer commented 4 years ago

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

thedmeyer commented 4 years ago

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