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

PlantUML include resolver is not available in the Ruby extension #259

Open
mskyaxl opened this issue May 13, 2021 · 3 comments
Open

PlantUML include resolver is not available in the Ruby extension #259

mskyaxl opened this issue May 13, 2021 · 3 comments

Comments

@mskyaxl
Copy link

mskyaxl commented May 13, 2021

Hi,

I am trying to create a set of libraries of files that are included in most of my plantuml diagrams and I'm having a hard time figuring out why kroki-plantuml-include-paths is not working

My setup:

Ubuntu 20.04 on which I have

  • a local kroki server started with the follwoing docker compose file:
version: "3"
services:
  kroki:
    image: yuzutech/kroki
    environment:
      - KROKI_SAFE_MODE=UNSAFE
      - KROKI_PLANTUML_ALLOW_INCLUDE=true
    ports:
      - "8000:8000"
  • the official docker container which I started with
docker run -it --rm -v $(pwd):/documents asciidoctor/docker-asciidoctor

and to which I installed the gem using

gem install asciidoctor-kroki
  • and a small project

lib.puml

@startuml lib

skinparam sequence {
ActorBorderColor Black
LifeLineBorderColor black
ParticipantBorderColor black
ArrowColor Black
LifeLineBackgroundColor black
}

@enduml

seq.puml

@startuml

!include ./lib.puml

Actor A
Actor B

A -> B: test
A <-- B: response
@enduml

test.adoc

:doctype: book
:backend-html5:
:doctitle: test

:kroki-server-url: http:https://172.17.0.1:8000
:kroki-fetch-diagram:
:kroki-plantuml-include-paths: {docdir}
:imagesdir: images

{kroki-plantuml-include-paths}

[[section-adoc]]

= adoc

[plantuml]
....
include::seq.puml[]
....

all the files are in the same directory(mounted to /documents to docker)

bash-5.1# asciidoctor -r asciidoctor-kroki test.adoc
asciidoctor: FAILED: /documents/test.adoc: Failed to load AsciiDoc document - 400 Bad Request
  Use --trace for backtrace

Kroki log shows

{"timestamp":"1620972621879","level":"ERROR","thread":"vert.x-eventloop-thread-1","mdc":{"error_message":"cannot include ./lib.puml (line: 2)","path":"/plantuml/svg/eNpzKC5JLCopzc3h4lLMzEvOKU1JVdDTz8lM0isACzoml-QXKThCaSeggIKunYKTlUJJanEJkGOjqwviFaUWF-TnFadyOaTmpQA1AgCk_hqg","method":"GET","action":"error","error_code":"400","failure_class_name":"io.kroki.server.error.BadRequestException","user_agent":"Ruby"},"logger":"io.kroki.server.error.ErrorHandler","message":"An error occurred","context":"default","exception":"io.kroki.server.error.BadRequestException: cannot include ./lib.puml (line: 2)\n\tat io.kroki.server.service.Plantuml.convert(Plantuml.java:269)\n\tat io.kroki.server.service.Plantuml.lambda$convert$5(Plantuml.java:235)\n\tat io.vertx.core.impl.ContextImpl.lambda$null$0(ContextImpl.java:179)\n\tat io.vertx.core.impl.AbstractContext.dispatch(AbstractContext.java:96)\n\tat io.vertx.core.impl.ContextImpl.lambda$executeBlocking$1(ContextImpl.java:177)\n\tat io.vertx.core.impl.TaskQueue.run(TaskQueue.java:76)\n\tat java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)\n\tat java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)\n\tat io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)\n\tat java.base/java.lang.Thread.run(Unknown Source)\n"}
  1. using :kroki-plantuml-include: {docdir}/lib.puml worked but this is not enough for me as I have different includes for different files.
  2. removing the include also generates the document successfully

My project is more complicated than this, with a more elaborated folder structure but I strip it down to the simplest form and not even this works.

What am I doing wrong?

@ggrossetie
Copy link
Member

kroki-plantuml-include-paths is currently only supported when using the JavaScript extension.
So this feature needs to be implemented in the Ruby extension as well.

@ggrossetie ggrossetie changed the title plantuml include does not work PlantUML include resolver is not available in the Ruby extension Aug 19, 2021
@asciidoctor asciidoctor deleted a comment from jvmlet Aug 22, 2021
@asciidoctor asciidoctor deleted a comment from jvmlet Aug 22, 2021
@archiloque
Copy link
Contributor

@Mogztter I'm interested in working on this issue but I don't know how to start it, for example Asciidoctor::PreprocessorReader#resolve_include_path doesn't seem to support a list of possible directories to look into, could you explain how the case should be handled? Thanks!

@ggrossetie
Copy link
Member

I'm interested in working on this issue but I don't know how to start it, for example Asciidoctor::PreprocessorReader#resolve_include_path doesn't seem to support a list of possible directories to look into, could you explain how the case should be handled? Thanks!

We should use our own mechanism. Asciidoctor::PreprocessorReader#resolve_include_path is used to resolve the include:: directive in Asciidoctor. The PlantUML !include directive achieves a similar goal but does not work exactly the same.

The goal here is to implement the following JavaScript function in Ruby:

https://github.com/Mogztter/asciidoctor-kroki/blob/6e6d86c6fca8a8a633eabf742b0fb8aac8b0d206/src/preprocess.js#L90

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants