Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
thedmeyer opened this issue Jan 29, 2020 · 5 comments

Comments

@thedmeyer
Copy link

thedmeyer commented Jan 29, 2020

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
Copy link
Author

Looking through the code. I did not realize this action is relying on an external API...

const res = await axios.get(`http://www.plantuml.com/plantuml/svg/${encoded}`);

@grassedge
Copy link
Owner

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

@grassedge
Copy link
Owner

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
Copy link
Author

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

@thedmeyer
Copy link
Author

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

grassedge pushed a commit that referenced this issue Aug 7, 2020
Add support for `.pml`, `.puml` and `.plantuml` extensions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants