I’m a big fan of Markdown. I really love this idea of lightweight markup – you write plain text, mix it with formatting instructions and get your text formatted. I like it, because it feels very similar to writing the code.
Asciidoctor is another lightweight markup processor. It’s similar to Markdown, but more powerful – it can do more than just making your text bold or underlined. Asciidoctor is what Spring team uses to write their documentation.
It’s usually hard to write a large document with Markdown. Markdown doesn’t have tools to combine a few smaller documents into a single one. Asciidoctor helps you to build larger documents from smaller ones using the include directive:
I am part one.
I am part two.
= My Book
One of the popular use-cases for Markdown is technical blogging. You write some text that explains what problem you had, you show a piece of code, and then explain how it solves the problem. With Markdown, you have to copy that code into your Markdown markup. With Asciidoctor your can really include the code without copying:
This feature is super nice, because it ensures that your documentation is always up to date with the source code. Imagine how you include a piece of your test to explain how something works. This code may change later, but the only thing you’ll have to do is to rebuild your documentation.
One of the nice Asciidoctor extensions is asciidoctor-diagram. This extension allows you to use PlantUML right inside your document, so that you don’t have to jump back and forth between text editor and diagram editor:
= Hard to explain
If it’s the first time you read about PlantUML, definitely do spend 15 minutes to learn more. It’s not just about activity diagrams – they also support class, component and sequence diagrams. There’s also a nice online editor planttext.com with a plenty of sample diagrams.
Asciidoctor integrates nicely with Java projects (see asciidoctor-gradle-plugin) and makes it easy to make documentation one of your build artifacts. The closer you keep your documentation to the code, the easier it is to keep it up to date.
All examples from this post are available in this GitHub repository.