asciidoctor / asciidoctorj

:coffee: Java bindings for Asciidoctor. Asciidoctor on the JVM!
http://asciidoctor.org
Apache License 2.0
618 stars 172 forks source link

Unrecognized plantuml !theme keyword #1064

Open gregLibert opened 2 years ago

gregLibert commented 2 years ago

Hello,

When I try to generate documentation containing plantuml diagram with !theme keyword, the application raises a syntax error:

....
@startuml
!theme cerulean-outline
^^^^^
 Syntax Error?

        at org.asciidoctor.jruby.internal.JRubyAsciidoctor.convertFile(JRubyAsciidoctor.java:402)
        at org.asciidoctor.jruby.internal.JRubyAsciidoctor.convertFile(JRubyAsciidoctor.java:416)
        at org.asciidoctor.jruby.internal.JRubyAsciidoctor.convertFile(JRubyAsciidoctor.java:411)
        at org.asciidoctor.jruby.cli.AsciidoctorInvoker.renderInput(AsciidoctorInvoker.java:162)
        at org.asciidoctor.jruby.cli.AsciidoctorInvoker.invoke(AsciidoctorInvoker.java:73)
        at org.asciidoctor.jruby.cli.AsciidoctorInvoker.main(AsciidoctorInvoker.java:211)
Caused by: org.jruby.exceptions.RuntimeError: (RuntimeError) asciidoctor: FAILED: c:/Users/XXXXX/Documents/YYYY/ZZZ - VT 0.0.adoc: Failed to load AsciiDoc document - PlantUML preprocessing failed: [From <input> (line 3) ]
...

I'm using 2.5.2 package version.

Is asciidoctorj-diagram-2.1.2.jar obsolete? What kind of information/test can I do to clarify the issue?

R

abelsromero commented 2 years ago

Is asciidoctorj-diagram-2.1.2.jar obsolete?

Latest asciidoctorj-diagram is 2.2.1, can you try with it? IntelliJ preview works fine and since it uses AsciidoctorJ at least we know it's possible.

image

What kind of information/test can I do to clarify the issue?

If you can provide a reproducer it would be really helpful.

gregLibert commented 2 years ago

Thank you @abelsromero for your feedback!

I'm generating the document using the CLI on windows and not IntelliJ (I wish I could...).

Using the flowing file (test_windows.adoc):

== Let's use a diagram

.Awesome first diagram
[plantuml, first_diagram, svg]
....
@startuml
!theme spacelab
class Example {
  Theme spacelab
}
@enduml
....

with the following command :

c:\Users\XXX\Apps\asciidoctorj-2.5.2\bin\asciidoctorj.bat -r asciidoctor-diagram test_windows.adoc

I have the following error:

...
@startuml
!theme spacelab
^^^^^
 Syntax Error?

        at RUBY.load(uri:classloader:/gems/asciidoctor-2.0.16/lib/asciidoctor/load.rb:104)
        at RUBY.convert(uri:classloader:/gems/asciidoctor-2.0.16/lib/asciidoctor/convert.rb:78)
        at RUBY.convert_file(uri:classloader:/gems/asciidoctor-2.0.16/lib/asciidoctor/convert.rb:190)
        at org.jruby.RubyIO.open(org/jruby/RubyIO.java:1158)
        at RUBY.convert_file(uri:classloader:/gems/asciidoctor-2.0.16/lib/asciidoctor/convert.rb:190)
...

I have downloaded asciidoctorj-diagram-2.2.1.jar, modified asciidoctorj.bat file to use this jar instead of 2.1.2 one, but I've got another error:

Java HotSpot(TM) Client VM warning: TieredCompilation is disabled in this release.
Exception in thread "main" org.jruby.exceptions.LoadError: (MissingSpecError) Gem::MissingSpecError
        at RUBY.to_specs(uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/rubygems/dependency.rb:311)
        at RUBY.activate_dependencies(uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/rubygems/specification.rb:1400)
        at org.jruby.RubyArray.each(org/jruby/RubyArray.java:1809)
        at RUBY.activate_dependencies(uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/rubygems/specification.rb:1389)
        at RUBY.activate(uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/rubygems/specification.rb:1371)
        at RUBY.try_activate(uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/rubygems.rb:217)
        at RUBY.require(uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:151)
        at RUBY.<main>(<script>:1)

I can perform other tests if that helps.

abelsromero commented 2 years ago

Curious, a simple program as shown below is fine, but indeed v2.5.2 cli fails. I'll will continue looking into it later.

    public static void main(String[] args) {
        Asciidoctor asciidoctor = Asciidoctor.Factory.create();
        asciidoctor.requireLibraries(List.of("asciidoctor-diagram"));

        Attributes attributes = Attributes.builder()
                                          .build();

        Options options = Options.builder()
                                 .backend("html5")
                                 .safe(SafeMode.UNSAFE)
                                 .mkDirs(true)
                                 .toDir(new File("build"))
                                 .attributes(attributes)
                                 .build();

        asciidoctor.convertFile(file("diagrams.adoc"), options);
    }

@gregLibert what's your use case? Until we see what's going on maybe we can suggest some alternative.

gregLibert commented 2 years ago

@abelsromero my use case is pretty simple (and limited):

Maybe I can reuse your code sample to generate my documentation ?

abelsromero commented 2 years ago

I was asking more in the line of goals, like "just exploring", "looking for options to integrate in CI". If your are tied to JVM, you can also try using the maven plugin or gradle, the respective wrappers will take care of installing dependencies.

Here is an example using diagrams, https://github.com/asciidoctor/asciidoctor-maven-examples/tree/main/asciidoctor-diagram-example. I tested the example you provided and it works fine (which makes me wonder what's the issue with cli)

abelsromero commented 2 years ago

I was looking into it and found that running from the embedded terminal in IntelliJ works :dizzy_face: Running same Java and Asciidoctorj version

openjdk version "17" 2021-09-14
OpenJDK Runtime Environment Temurin-17+35 (build 17+35)
OpenJDK 64-Bit Server VM Temurin-17+35 (build 17+35, mixed mode, sharing)
OpenJDK 64-Bit Server VM warning: Options -Xverify:none and -noverify were deprecated in JDK 13 and will likely be removed in a future release.
2021-11-14T10:52:35.704+01:00 [main] WARN FilenoUtil : Native subprocess control requires open access to the JDK IO subsystem
Pass '--add-opens java.base/sun.nio.ch=ALL-UNNAMED --add-opens java.base/java.io=ALL-UNNAMED' to enable.
AsciidoctorJ 2.5.2 (Asciidoctor 2.0.16) [https://asciidoctor.org]
Runtime Environment: jruby 9.2.17.0 (2.5.8)
mathze commented 7 months ago

Maybe a bit late but for other stumbling over this issue. I use the org.asciidoctor.jvm.convert gradle plugin version 3.3.2 and encountered same issue. I was able to solve it by upgrading asciidoctorj to 2.5.10 and asciidoctorj-diagram to 2.2.13

In gradle (kotlin-dsl) this looks like

asciidoctorj {
  modules {
    diagram.apply {
      use()
      version("2.2.13")
    }
  }
  setVersion("2.5.10")
}