Home : Documentation : Part III. For ACS Developers : 6. Engineering Standards : 2. aD DocBook Primer 

2. aD DocBook Primer

Table of Contents

2.1. Why DocBook?
2.2. Document Structure
2.3. Headlines, Sections
2.4. Code
2.5. Links
2.6. Graphics
2.7. Lists
2.8. Tables
2.9. Emphasis
2.10. Indexing Your DocBook Documents
2.11. Tools
2.12. Publishing
2.13. Revision History

By claus@arsdigita.com

2.1. Why DocBook?

In order to separate content and presentation, all ACS documentation will be marked up to conform to the DocBook XML DTD (Check the XML source of this document to get an idea of what it looks like). This enables us to publish in a variety of formats and relieves each contributor of the burden of presentation, freeing him to focus on content and sharing knowledge.

Theoretically any strict DTD would have been sufficient - we could even write our own. But DocBook has been around for a while (since early 90's), it's well-tested, it's complete, it's extremely well-suited for technical documents and best of all, it's open-source. A growing community surrounds DocBook (has mailing lists) and a number of free and commercial tools are available for editing and publishing DocBook documents.

This primer walks you through the basics, and should cover the needs for 95 percent of the documentation we produce. However, you're always welcome to check out DocBook's list of elements and use more exotic features in your documents. The list is made up of SGML-elements but basically the same elements are valid in the XML DTD as long as you remember to:

  • Always close your tags with corresponding end-tags and to not use other tag minimization

  • Write all elements and attributes in lowercase

  • Quote all attributes

2.2. Document Structure

The documentation for each package will make up a little "book" that is structured like this - examples are emphasized:

    book                        : Docs for one package - templating
     |
     +--chapter                 : One section - for developers
         |
---------+------------------------------------------------------
         |
         +--sect1               : Single document - requirements
             |
             +--sect2           : Sections - functional requirements
                 |
                 +--sect3       : Subsections - Programmer's API
                     |
                    ...         : ...

The actual content is split up into documents that start at a sect1-level. These are then tied together in a top-level document that contains all the information above the line. This will be explained in more detail in a later document, and we will provide a set of templates for documenting an entire package.

For now you can take a look at the sources of these DocBook documents to get an idea of how they are tied together.

2.3. Headlines, Sections

Given that your job starts at the sect1-level, all your documents should open with a <sect1>-tag and end with the corresponding </sect1>.

You need to feed every <sect1> two attributes. The first attribute, id, is standard and can be used with all elements. It comes in very handy when interlinking between documents (more about this when talking about links in Section 2.5.). The value of id has to be unique throughout the book you're making since the id's in your sect1's will turn into filenames when the book is parsed into HTML.

The other attribute is xreflabel. The value of this is the text that will appear as the link when referring to this sect1.

Right after the opening tag you put the title of the document - this is usually the same as xreflabel-attribute. E.g. the top level of the document you're reading right now looks like this:

<sect1 id="docbook-primer" xreflabel="aD DocBook Primer">
<title>aD DocBook Primer</title>

...

</sect1>

Inside this container your document will be split up into <sect2>'s, each with the same requirements - id and xreflabel attributes, and a <title>-tag inside. Actually, the xreflabel is never required in sections, but it makes linking to that section a lot easier.

When it comes to naming your sect2's and below, prefix them with some abbreviation of the id in the sect1 such as requirements-overview.

2.4. Code

For displaying a snippet of code, a filename or anything else you just want to appear as a part of a sentence, we will use the tag <computeroutput>. This takes the place of the HTML-tag <code>

For bigger chunks of code such as SQL-blocks, the tag <programlisting> is used. Just wrap your code block in it; mono-spacing, indents and all that stuff is taken care of automatically.

2.6. Graphics

NOTE: Currently this section currently only takes HTML-output into consideration - not a printed version

Another Note: Also, it's still not a 100 percent sure that this is how we are going to do it, so if you want to start converting your documents right away, start out with the ones without graphics ;)

To insert a graphic we use the elements <mediaobject>, <imageobject>, and <imagedata>. The news is that you have to provide two versions of all your graphics - one for the Web (probably a GIF or a JPEG) and one for print (EPS). Finally you should provide a brief description wrapped in <textobject> - in HTML this will be the ALT text.

<mediaobject>
  <imageobject>
    <imagedata fileref="../images/rp-flow.gif" format="GIF" align="center"/>
  </imageobject>
  <imageobject>
    <imagedata fileref="../images/rp-flow.eps" format="EPS" align="center"/>
  </imageobject>
  <textobject>
    <phrase>This is an image of the flow in the Request Processor</phrase>
  </textobject>
</mediaobject>

Put your graphics in a separate directory ("images") and link to them only with relative paths.

2.7. Lists

Here's how you make the DocBook equivalent of the three usual HTML-lists:

1. How to make an <ul>

Making an unordered list is pretty much like doing the same thing in HTML - if you close your <li>, that is. The only differences are that each list item has to be wrapped in something more, such as <para>, and that the tags are called <itemizedlist> and <listitem>:

  <itemizedlist>
  
    <listitem><para>Stuff goes here</para><listitem>
    <listitem><para>More stuff goes here</para><listitem>

  </itemizedlist>
  
2. How to make an <ol>

The ordered list is like the preceding, except that you use <orderedlist> instead:

  <orderedlist>
  
    <listitem><para>Stuff goes here</para><listitem>
    <listitem><para>More stuff goes here</para><listitem>

  </orderedlist>
  
3. How to make a <dl>

This kind of list is called a variablelist and these are the tags you'll need to make it happen: <variablelist>, <varlistentry>, <term> and <listitem>:

  <variablelist>
  
    <varlistentry>
      <term>Heading (<dt>) goes here</term>
      <listitem><para>And stuff (<dd>)goes here</para><listitem>
    </varlistentry>

    <varlistentry>
      <term>Another heading goes here</term>
      <listitem><para>And more stuff goes here</para><listitem>
    </varlistentry>

  </variablelist>
  

2.8. Tables

DocBook supports several types of tables, but in most cases, the <informaltable> is enough:

<informaltable frame="all">
<tgroup cols="3">
<tbody>

  <row>
    <entry>a1</entry>
    <entry>b1</entry>
    <entry>c1</entry>
  </row>

  <row>
    <entry>a2</entry>
    <entry>b2</entry>
    <entry>c2</entry>
  </row>

  <row>
    <entry>a3</entry>
    <entry>b3</entry>
    <entry>c3</entry>
  </row>

</tbody>
</tgroup>
</informaltable>

With our current XSL-style-sheet, the output of the markup above will be a simple HTML-table:

a1b1c1
a2b2c2
a3b3c3

If you want cells to span more than one row or column, it gets a bit more complicated - check out <table> for an example.

2.9. Emphasis

Our documentation uses two flavors of emphasis - italics and bold type. DocBook uses one - <emphasis>.

The <emphasis> tag defaults to italics when parsed. If you're looking for emphasizing with bold type, use <emphasis role="strong">.

2.10. Indexing Your DocBook Documents

Marking up index-words may not have any importance for the HTML-output, but in order to make it easier to make a nice print-version of the documentation, you should mark up words in your documents that you would like to see show up in an index one day.

Use <indexterm>, <primary> and <secondary> for this. See these links for an explanation and the source of this document for examples.

2.11. Tools

  • David Lutterkort wrote an intro to the PSGML Mode in Emacs

  • For checking if your document is well-formed, James Clark's free Java parser, XP, is recommended. (note that it is not a validating parser, but as long as you follow the guidelines set forth in this document, your XML will validate)

  • DocBook Tool for Linux: Let's you convert your docbook documents to a number of formats. Sometimes it's nice to see how you stuff looks.

  • AptConvert from PIXware is a Java editor that will produce DocBook documents and let you transform them into HTML and PDF for a local preview before you submit.

  • In the process of transforming your HTML into XML, HTML tidy can be a a handy tool to make your HTML "regexp'able". Brandoch Calef has made a Perl script that gets you most of the way.

2.12. Publishing

You shouldn't worry about publishing you documents - that's the idea of separating content from presentation.

Exactly how the documentation will be published is not finalized yet. The current idea is to keep all the documentation in raw XML under CVS and then parse it with what ever style-sheet we choose upon release.

2.13. Revision History

Document Revision #Action Taken, NotesWhen?By Whom?
0.2Changed recommendation from <phrase> to <emphasis role="strong">01/19/2000Claus Rasmussen
0.1Creation12/2000Claus Rasmussen