Open pdiefent opened 4 years ago
It sounds to me like you have not enabled the extension. Are you passing the -r asciidoctor-diagram
flag when invoking the asciidoctor-pdf
command?
I'm using a gradle Build and yes, I do not use the flag you are mentioning. To be honest, I'm not sure where to place it in the build commands :(
// common settings for asciidoctor // this is needed for PDF generation with plantUML tasks.withType(AsciidoctorTask) { docTask -> backends = ['pdf']
options doctype: 'book',
'source-highlighter': 'coderay'
attributes icons: 'font',
'pdf-stylesdir': project.stylesDir.toString(),
'pdf-fontsdir': project.fontsDir.toString(),
'chapter-label': '',
'docdate': getDate()
// good to see what the build is doing...
logDocuments = true
}
You need two things:
See https://asciidoctor.github.io/asciidoctor-gradle-plugin/development-3.x/user-guide/#diagram
All required libraries are on the classpath and all inline plantuml code works well:
If I put the code in a external file with puml extension the above mentioned mechanisms do not work. The IntelliJ-AsciiDoc plugin works well also.
The task configuration
asciidoctorj { modules { diagram.use() diagram.version '1.5.16' } }
is not accepted by gradle and produces error messages:
A problem occurred evaluating root project 'Architekturkonzept'.
Could not find method modules() for arguments [build_6frr3tw0crxtpggzh4wo60a9e$_run_closure5$_closure17@35e74dd2] on object of type org.asciidoctor.gradle.AsciidoctorExtension.
You can set it globally
asciidoctorj {
modules {
diagram.use()
}
}
or on the task itself
asciidoctorPdf {
asciidoctorj {
modules {
diagram.use()
}
}
}
You can set it globally
asciidoctorj { modules { diagram.use() } }
or on the task itself
asciidoctorPdf { asciidoctorj { modules { diagram.use() } } }
that really doesn't help. I'm getting the same error message as before :(
Could not find method modules() for arguments [build_6frr3tw0crxtpggzh4wo60a9e$_run_closure5$_closure17@35e74dd2] on object of type org.asciidoctor.gradle.AsciidoctorExtension.
My build.gradle
plugins {
id "org.asciidoctor.jvm.pdf" version "3.3.0"
id "org.asciidoctor.jvm.gems" version "3.3.0"
}
apply plugin: "java"
version = "0.1.0-SNAPSHOT"
repositories {
ruby.gems()
mavenCentral()
}
dependencies {
asciidoctorGems "rubygems:rouge:3.15.0"
}
asciidoctorPdf {
dependsOn asciidoctorGemsPrepare
baseDirFollowsSourceFile()
asciidoctorj {
modules {
asciidoctorj {
version "2.5.6"
}
pdf {
version "2.3.0"
}
diagram {
version "2.2.3"
}
}
requires "rouge"
sources { include "project-ext-pml.adoc" }
options safe: 'unsafe'
attributes "build-gradle": file("build.gradle"),
"jrubyVersion": "9.3.8.0",
"safeMode": "UNSAFE",
"showtitle": "true",
"allow-uri-read": "true",
"source-highlighter": "rouge",
"icons": "font",
"imagesdir": "images",
"experimental": "true"
}
}
// alias
task asciidoctor(dependsOn: asciidoctorPdf)
My project-ext-pml.adoc
= Plant UML Diagram Demo
:toc: left
== Plant UML Inside
REF https://docs.asciidoctor.org/diagram-extension/latest/ , `Anatomy of a diagram`
REF https://docs.asciidoctor.org/diagram-extension/latest/ , `PlantUML Diagram Syntax`
.Plant UML Inside
[plantuml, target=diagram-classes-AAA, format=png]
....
class BlockProcessorAAA
class DiagramBlock
class DitaaBlock
class PlantUmlBlock
BlockProcessorAAA <|-- DiagramBlock
DiagramBlock <|-- DitaaBlock
DiagramBlock <|-- PlantUmlBlock
....
== Plant UML External File
REF https://docs.asciidoctor.org/diagram-extension/latest/#diagram-macros
**Anatomy of a diagram block macro**
`diagram-type::source-file-name[format=output-format]`
.Plant UML External File
plantuml::project1.pml[target=diagram-classes-ext-project1,format=png]
My project1.pml
class BlockProcessor
class DiagramBlock
class DitaaBlock
class PlantUmlBlock
BlockProcessor <|-- DiagramBlock
DiagramBlock <|-- DitaaBlock
DiagramBlock <|-- PlantUmlBlock
Run .gradlew clean asciidoctor
build/docs/asciidocPdf
├── images
│ ├── diagram-classes-AAA.png
│ └── diagram-classes-ext-project1.png
└── project-ext-pml.pdf
diagram-classes-AAA.png
diagram-classes-ext-project1.png
project-ext-pml.pdf Page 1
project-ext-pml.pdf Page 2 - External Plant UML File
Key point
FAIL project1.pml
contains plantuml header , remove it.
[plantuml, target=diagram-classes-AAA, format=png]
....
class BlockProcessorAAA
class DiagramBlock
class DitaaBlock
class PlantUmlBlock
BlockProcessorAAA <|-- DiagramBlock
DiagramBlock <|-- DitaaBlock
DiagramBlock <|-- PlantUmlBlock
....
TO My project1.pml
class BlockProcessor
class DiagramBlock
class DitaaBlock
class PlantUmlBlock
BlockProcessor <|-- DiagramBlock
DiagramBlock <|-- DitaaBlock
DiagramBlock <|-- PlantUmlBlock
Test Passed.
Hello, I'm editing a big assciidoc and I tried to include a PlantULM diagram from an external *.puml file. This is working fine within the IntelliJ-Plugin but the PDF generation doesn't render the diagram in the document. Instead, the souce code of the diagram description appears.
I tried both variants for includeing PlantULS-Descriptions:
Any ideas are appreciated, Peter