Documentation as Code

Balancing Writing & Delivery with Asciidoctor

Dan AllenOpenDevise

imagewriter banner
print shop box
print shop main menu
skull
imagewriter banner long
imagewriter color ribbon cartridge
print shop thinking

Creation

Writers Write

<?xml version="1.0" encoding="UTF-8"?>
<article xmlns="http://docbook.org/ns/docbook" version="5.0"
    xmlns:xl="http://www.w3.org/1999/xlink" xml:lang="en">
  <info>
    <title>Documentation as Code</title>
    <date>2016-11-02</date>
    <author>
      <personname>
        <firstname>Author</firstname>
        <surname>Name</surname>
      </personname>
      <email>author@example.org</email>
    </author>
    <authorinitials>AN</authorinitials>
    <revhistory>
      <revision>
        <revnumber>1.0.0</revnumber>
        <date>2016-11-02</date>
        <authorinitials>AN</authorinitials>
      </revision>
    </revhistory>
  </info>
  <abstract>
    <simpara>Start with an abstract&#8212;the façade of your article.</simpara>
  </abstract>
...

DocBook

...
  <section xml:id="_beginning">
    <title>Beginning</title>
    <itemizedlist>
      <listitem>
        <simpara>Mission</simpara>
      </listitem>
      <listitem>
        <simpara>Goals</simpara>
      </listitem>
    </itemizedlist>
  </section>
  <section xml:id="_middle">
    <title>Middle</title>
    <programlisting language="ruby" linenumbering="unnumbered"><![CDATA[
Asciidoctor.convert_file 'example.adoc', safe: :safe
]]></programlisting>
    <informalfigure>
      <mediaobject>
        <imageobject>
          <imagedata fileref="screenshot.png"/>
        </imageobject>
        <textobject>
          <phrase>Screenshot</phrase>
        </textobject>
      </mediaobject>
    </informalfigure>
...
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\begin{document}
\title{Documentation as Code}
\author{Author Name}
\maketitle
\tableofcontents
\begin{abstract}
Start with an abstract\textemdash{}\hspace{0em}the façade of your article.
\end{abstract}
\section{Beginning}
Here's the text of your introduction.
\begin{itemize}
\item{} Mission
\item{} Goals
\end{itemize}
\section{Middle}
\begin{listing1}[language=ruby,firstnumber=1,]
Asciidoctor.convert_file 'example.adoc', safe: :safe
\end{listing1}
\begin{figure}
\centering
\includegraphics[width=\imgwidth,height=\imgheight]{images/screenshot.png}
\end{figure}
\begin{DBKadmonition}{}{Note}
All good things must come to an end.
\end{DBKadmonition}
\section{End}
\textquotedblleft{}That's all, folks!\textquotedblright{}
\end{document}

LaTeX

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\begin{document}
\title{Documentation as Code}
\author{Author Name}
\maketitle
\tableofcontents
\begin{abstract}
Start with an abstract\textemdash{}\hspace{0em}the façade of your article.
\end{abstract}
\section{Beginning}
Here's the text of your introduction.
\begin{itemize}
\item{} Mission
\item{} Goals
\end{itemize}
\section{Middle}
\begin{listing1}[language=ruby,firstnumber=1,]
Asciidoctor.convert_file 'example.adoc', safe: :safe
\end{listing1}
\begin{figure}
\centering
\includegraphics[width=\imgwidth,height=\imgheight]{images/screenshot.png}
\end{figure}
\begin{DBKadmonition}{}{Note}
All good things must come to an end.
\end{DBKadmonition}
\section{End}
\textquotedblleft{}That's all, folks!\textquotedblright{}
\end{document}

Got ?

= Documentation as Code
Author Name <author@example.org>
v1.0.0, 2016-11-02
:toc: left

[abstract]
Start with an abstract--the façade of your article.

== Beginning

* Mission
* Goals

== Middle

[source,ruby]
----
Asciidoctor.convert_file 'example.adoc', safe: :safe
----

image::screenshot.png[Screenshot]

NOTE: All good things must come to an end.

== End

"`That's all, folks!`"

AsciiDoc

AsciiDoc is…​

A paragraph is just consecutive lines of text.
No special markup is required.

To start a paragraph, offset it by a blank line.
= Document Title

== Section Level 1

=== Section Level 2

==== Section Level 3

===== Section Level 4

====== Section Level 5

= Part Title (book doctype only)
* Atom
** Nuclide
* Brackets
* Light Table
. Step 1
.. Substep
. Step 2
. Step 3
*bold phrase*

_italic phrase_

`literal keyword`

[.type]#custom term#
image::tux.png[Tux,265,314]

video::SCZF6I-Rc4I[youtube,853,480]

icon:star[2x]
[.path]_gradle/wrapper/gradle-wrapper.properties_

[.topic]
== Service Workers

[.cue]
****
All the things to say.
****
align left
.AsciiDoc quick review
****
Here's a sample AsciiDoc document:

.Sample AsciiDoc document
[source,asciidoc]
----
= Document Title
Author Name
:toc: left

We'll show you how easy it is to...
----

* The document header is not required.
* You can set attributes via the commandline or API.
****

No WYSIWYG?!?

You Get What You Get

¯\_(ツ)_/¯

IDE for Writers

ss atom asciidoc preview
Atom

Creation

Recommended Practices

include::chapters/chapter01.adoc

[source,ruby]
----
include::{srcdir}/sample.rb[tag=refinement,indent=0]
----

Publication

[tabs]
======
.Visual Editor
[tab]
=====
Describe how to use the visual editor and show some screenshots.
=====

.XML Editor
[tab]
=====
Describe how to do the same thing in the XML editor.
=====
======

Transformation

lorem::sentences[5]
Asciidoctor::Extensions.register do
  block_macro :lorem do
    name_positional_attributes 'size'
    process do |parent, target, attrs|
      lorem = Middleman::Extensions::Lorem::LoremObject
      method = target.to_sym
      if lorem.respond_to? method
        content = lorem.send(method, attrs.fetch('length', 1).to_i.abs)
        create_paragraph parent, content, {}
      else
        warn 'Unknown lorem target for lorem block macro'
        nil
      end
    end
  end
end
  Scribed     Generated
        \     /
          \ /
           v
        AsciiDoc
           |
           v
       Converter
           |
           v
   Presentation Format

I can do truly amazing things with my AsciiDoc source.

Scott Chacon author of Pro Git

Publication

Recommended Practices

Push to Publish

Collaboration

The OpenShift team reported that after the migration from DocBook to AsciiDoc, the rate of both internal and external contributions skyrocketed—​from several a year to several a week. …​

…​ Mere days after our migration, we started seeing incoming Merge Requests, where there were none before. Preliminary results hint that this is an observable trend.

JBoss BxMS Engineering Team

git AsciiDoc

Edit on GitHub

Docs = Code

ss git changes
ss source diff
ss rich diff
ss code review

Collaboration

Recommended Practices

Write in AsciiDoc, Publish Everywhere!

Image Credits