asciidoctor / asciidoctor-ant

:ant: Ant task to render Asciidoc documentation
Apache License 2.0
9 stars 5 forks source link

Document how to use asciidoctor-diagram with asciidoctor-ant #53

Closed rockyallen closed 7 years ago

rockyallen commented 8 years ago

I downloaded the asciidoctor-ant-1.5.3 jar and copied it to my Windows machine, then ran

<?xml version="1.0" ?>
<project xmlns:asciidoctor="antlib:org.asciidoctor.ant">
    <target name="doc">
        <taskdef uri="antlib:org.asciidoctor.ant" 
           resource="org/asciidoctor/ant/antlib.xml" 
           classpath="lib/asciidoctor-ant-1.5.3.jar"/>
        <asciidoctor:convert sourceDirectory="src" outputDirectory="target"/>
    </target>
</project>

over:

[ditaa, "ditaa-diagram"]
----
                   +-------------+
                   | Asciidoctor |-------+
                   |   diagram   |       |
                   +-------------+       | PNG out
                       ^                 |
                       | ditaa in        |
                       |                 v
 +--------+   +--------+----+    /---------------\
 |        | --+ Asciidoctor +--> |               |
 |  Text  |   +-------------+    |   Beautiful   |
 |Document|   |   !magic!   |    |    Output     |
 |     {d}|   |             |    |               |
 +---+----+   +-------------+    \---------------/
     :                                   ^
     |          Lots of work             |
     +-----------------------------------+
----

The example below illustrates the structure of a basic PlantUML block written directly in an AsciiDoc document.
PlantUML Diagram Syntax

[plantuml, diagram-classes, png]
....
class BlockProcessor
class DiagramBlock
class DitaaBlock
class PlantUmlBlock

BlockProcessor <|-- DiagramBlock
DiagramBlock <|-- DitaaBlock
DiagramBlock <|-- PlantUmlBlock
....

but it gave:

[asciidoctor:convert] asciidoctor: WARNING: test2.adoc: line 4: invalid style for listing block: ditaa
[asciidoctor:convert] asciidoctor: WARNING: test2.adoc: line 27: invalid style for literal block: plantuml

As asciidoctor-ant wraps asciidoctor-j, and asciidoctor-j includes asciidoctor-diagram, I (naively) thought this would work.

Instructions or an example in the readme would be great.

binout commented 8 years ago

asciidoctor-ant wraps asciidoctorj-core (and asciidoctorj-pdf), but not asciidoctor-diagram ... You need to include it as an external gem (Cf. https://github.com/binout/asciidoctor-ant-examples#diagram).

I wish include asciidoctor-diagram, asciidoctor-epub in asciidoctor-ant 1.5.4, your opinion ?

rockyallen commented 8 years ago

Thanks for the link and examples. They would be very useful added to the readme, or linked.

Yes, please include asciidoctor-diagram in the same jar. How would you handle dot? If it cannot be packaged, could you give it a path-to-dot attribute, for those of us who aren't allowed to modify path.

It would be fantastic if you could do asciidoctor-epub as well, especially if you can include all the dependencies and get it to work offline on Windows! I think it should be a separate task, to match the separation in the Ruby programs.

robie2011 commented 6 years ago

My Workaround: https://stackoverflow.com/a/49690946/2248405