Asciidoctor Diagram is a set of extensions for Asciidoctor, the Ruby-based AsciiDoc processor. These extensions allow you to embed diagrams written using the PlantUML or Ditaa syntax inside your AsciiDoc documents. The extension takes care of running the diagram processor to generate the images from the input text and insert them into the rendered document.
This gem was inspired by the AsciiDoc PlantUML filter for AsciiDoc Python.
Installation
Add this line to your application’s Gemfile:
gem 'asciidoctor-diagram'
And then execute:
$ bundle
Or install it yourself as:
$ gem install asciidoctor-diagram
Usage
Enable the extensions
The diagram extensions consist of a set of block processors for Asciidoctor. In order to use extensions you should need to invoke Asciidoctor via the Ruby API. In your script you can then either require one or more of the following files:
-
asciidoctor-diagram
: to enable all the diagramming extensions -
asciidoctor-diagram/ditaa
: to enable the ditaa extension -
asciidoctor-diagram/graphviz
: to enable the graphviz extension -
asciidoctor-diagram/plantuml
: to enable the plantuml extension
Requiring one or more of these files will automatically register the extensions for all processed documents.
If you need more fine grained control over when the extensions are enabled or not, asciidoctor-diagram/ditaa/extension
, asciidoctor-diagram/graphviz/extension
and asciidoctor-diagram/plantuml/extension
can be used instead.
These load the extensions themselves but do not register them.
You should then register the extensions yourself at the appropriate time using the Asciidoctor::Extensions
API.
Using the extensions
Once the extensions are enabled support for ditaa
, graphviz
and plantuml
blocks becomes available for your documents.
Detailed descriptions of the supported syntax inside these blocks is available on the PlantUML, Graphviz and ditaa websites.
At this point you can start adding diagrams to your application, like the following example:
["plantuml", "asciidoctor-diagram-classes", "png"]
---------------------------------------------------------------------
class BlockProcessor
class DiagramBlock
class DitaaBlock
class PlantUmlBlock
BlockProcessor <|-- DiagramBlock
DiagramBlock <|-- DitaaBlock
DiagramBlock <|-- PlantUmlBlock
---------------------------------------------------------------------
The diagram blocks support the following attributes:
-
target
(or 2nd position): the basename of the file to generate. If not specified an auto-generated name will be used. -
format
(or 3rd position): the output format. PlantUML blocks supportpng
,svg
andtxt
. Graphviz supportspng
andsvg
. Ditaa only supportspng
.
Contributing
-
Fork it
-
Create your feature branch (
git checkout -b my-new-feature
) -
Commit your changes (
git commit -am 'Add some feature'
) -
Push to the branch (
git push origin my-new-feature
) -
Create new Pull Request