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

Resolve relative PlantUML includes from the diagram directory (not from the Asciidoctor base directory) #201

Closed
ggrossetie opened this issue Jan 23, 2021 · 2 comments · Fixed by #216

Comments

@ggrossetie
Copy link
Member

Let's take an example:

docs
├── diagrams
│   ├── hello.puml
│   └── style.puml
└── index.adoc

docs/index.adoc

plantuml::diagrams/hello.puml[]

docs/diagrams/hello.puml

!include ./style.puml

Bob->Alice: Hello

docs/diagrams/style.puml

skinparam monochrome true

Currently, the extension won't resolve style.puml because the path is resolved from the base directory.

Skipping preprocessing of PlantUML include, because reading the referenced local file './style.puml' caused an error:
Error: ENOENT: no such file or directory, open './style.puml'

In the above example the resolved path will be docs/style.puml instead of docs/diagrams/style.puml.

Implementation-wise, the last parameter should be the diagram directory and not the base directory:

https://github.com/Mogztter/asciidoctor-kroki/blob/1372acb3bad3cad143fcbab5a7c8aaa5f802cfb7/src/asciidoctor-kroki.js#L76

This issue is a follow-up of: #191 (where we did this change for Vega diagrams)

@romkavt
Copy link

romkavt commented Feb 10, 2021

I vote for this issue!

I experiencing difficulties with multi-file & multi-directory documentation project.
We are using plantuml include directives with relative paths to parent plantuml document.
asciidoctor-kroki preprocessor builds include file paths relative to main asciidoctor documents.

As the consequences we have:

  • unable to keep plantuml diagrams in separate dir to asciidoctor document (for example ./images)
  • unable to split large asciidoctor book to a couple for smaller asciidoctor documents in separate directories

@anb0s
Copy link
Contributor

anb0s commented Feb 10, 2021

The plantuml preprocessor here use definition like supported in PlantUML via parameter plantuml.include.path and implicitly set it to doc.getBaseDir(). This behaviour works for us, because we have used property -Dplantuml.include.path=${docBaseDir} for preprocessing and then always use this as base path for all includes, e.g. !include ./diagrams/style.iuml.

I think this can be changed to have the implicit behaviour like -Dplantuml.include.path=${diagramDir} and resolve from the first included diagram. But we need additionally also the support of parameter plantuml.include.path= similiar to PlantUML core for other valid use cases.

anb0s added a commit to anb0s/asciidoctor-kroki that referenced this issue Feb 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants