PlantUML Plugin for Octopress

What is PlantUML?

PlantUML is a component that allows to quickly write:

  • sequence diagram,
  • use case diagram,
  • class diagram,
  • activity diagram,
  • component diagram,
  • state diagram
  • object diagram

I really like the idea of writing UML diagram with plain text. Since it’s totally plaintext, it’s very easy to do diff and version track, also you don’t need to do anything about the layout (the text itself looks pretty good too).

Also the syntax of it is very well designed, and the generated diagrams looks really nice, so I use PlantUML for technical documentation with trac and sphinx.

The Plugin

After switching Octopress to my blog platform, I was looking for a way to integrate PlantUML within it, though I can’t find one, so I wrote this very simple jekyll plugin (Octopress is based on Jekyll).

jekyll-plantuml

Configuration

You need to download the plantuml.jar file from http://plantuml.sourceforge.net/download.html

In your _config.xml, setup plantuml_jar to the downloaded jar file, e.g.

plantuml_jar: ../_lib/plantuml.jar
plantuml_background_color: "#f8f8f8"

The plantuml_background_color is optional, which will change the background of the generated diagram.

Usage

Just wrap the diagram text in “plantuml” block, e.g.

{% plantuml %}
Alice -> Bob: Authentication Request
Bob --> Alice: Authentication Response

Alice -> Bob: Another authentication Request
Alice <-- Bob: another authentication Response
{% endplantuml %}

An Example

comments powered by Disqus