Table of Contents
List of Figures
List of Tables
List of Examples
Wikbook is a set of tools for efficiently writing docbook documentation. For this purpose several choices have been made that are explained below
Wikbook aims also to provide exclusive features that makes documentation easier to write. The perfect example we like to give is the inclusion of Javatm source code at the heart of the documentation as it allows to have always up to date example that stay in sync with the documentation. The goal is to make the documentation easier to write and maintain.
Wikbook is also a lab to experiment new things and we are sure that it will get richer over time. We hope that people will find Wikbook interesting to write their documentation, experiment new ideas and contribute them.
Wikbook aims to be open and does not want to lock users into a proprietary system. The proof is that Wikbook is based on the open Docbook format.
This document is a work in progress and will get richer over time.
Table of Contents
Wiki syntaxes are not unique, Wikbook relies on an external framework used at the hear of XWiki that is able to make wiki syntaxes coexist. Any wiki syntax recognized by this framework can be used for documentation writing. The following syntaxes are recognized:
For the purpose of simplicity, the Wikbook documentation uses the XWiki 2.0 syntax.
Wikbook attempts to fully leverage the wiki syntax, however the horizontal rule wiki syntax is not supported. Indeed there is no such concept in the docbook system and horizontal rule are simply ignored.
Table of Contents
Wiki concepts are naturally mapped onto docbook concepts.
A book is structured into chapters and each chapter is structured into sections. A wiki document provides a syntax for creating nested sections with different levels. The book structure can naturally leverage the wiki document structure with the following rules:
Table 2.1.
= Section 1 = == Section 2 == | <chapter> <title>Section 1</title> <section> <title>Section 2</title> </section> </chapter> |
All wiki sections don't have to be explicitely declared, it is possible to omit the declaration of a section. When it occurs, implicit docbook section will be created with no title.
The content of a book can be seen as a collection of content, each content can be categorized into blocks or rich text. Rich text can either be simple text or it can be made richer, like a word in bold. A block contains usually rich text and gives a meaning to the text, the most natural block is the paragraph.
The following syntax can be used to put the emphasis for creating richtext
Table 2.2. Text emphasis
**bold** | bold |
//italic// | italic |
__underline__ | underline |
,,subscript,, | subscript |
^^upperscript^^ | upperscript |
--strikethrough-- | strikethrough |
##monospaced## | monospaced |
{{code}}inlineCode(){{/code}} | inlineCode() |
We can distinguish two kinds of links. A link can reference a target inside the document such as an anchor or a section or it can reference an URL.
The anchor macro plays an important role in internal links as it specifies the potential target of a link. Any internal link should reference a valid anchor inside the document. An anchor can be placed anywhere in text but it can also be present in a section title.
Table 2.3. Document links
= Chapter 1 {{anchor id=chapter_1 /}} = A [[link>>#chapter_1]] to the chapter 1 The [[#chapter_1]] can be linked A [[link>>#foo]] to an anchor {{anchor id=foo /}} | <chapter> <title>Chapter 1</title> <para>A <link linkend="chapter_1">link</link> to the chapter 1</para> <para>The <xref linkend="chapter_1"/> can be linked</para> <para>A <link linkend="foo">link</link> to an anchor</para> </chapter> |
Verbatim escapes the wiki syntax and is useful for citing wiki in a wiki document. It is useful for creating document such as this documentation.
Unlike docbook, wiki paragraphs are implicitely defined, the general rule is that any text content that does not contain wiki instruction is one paragraph. The wikbook system creates docbook paragraphs when it is required. The simplest example is that any content in a section is a paragraph.
Table 2.6. Paragraph generation
= Chapter 1 = The paragraph of the chapter 1. == Section 1 == The paragraph of the section 1. == Section 2 == The first paragraph of the section 2. The second paragraph of the section 2. | <chapter> <title>Chapter 1</title> <para>The paragraph of the chapter 1.</para> <section> <title>Section 1</title> <para>The paragraph of the section 1.</para> </section> <section> <title>Section 2</title> <para>The first paragraph of the section 2.</para> <para>The second paragraph of the section 2.</para> </section> </chapter> |
It is easy to create lists in wiki syntax, whereas the docbook XML is very tedious. Several types of lists are possible such as bullet or ordered list.
Table 2.7. List examples
* item 1 ** item 1.1 ** item 1.2 * item 2 |
|
1. item 1 11. item 1.1 11. item 1.2 1. item 2 |
|
(% style="upperroman" %) 1. item 1 11. item 1.1 11. item 1.2 1. item 2 |
|
It is possible to configure also the list style according to the docbook capabilities.
Tables are mapped to the docbook tables, here are a few examples
By default a table expects inline content, that means that any content inside the table will not be interpreted as wiki text but as normal text. It is possible to change that behavior with the usage of the (((...))) block allowing the usage of nested tables or lists.
This document makes an extensive usage of this feature.
Inside a complex content block, the usage of structural elements such as section is not allowed.
Images can be displayed a block elements. Image display can be parameterized for all output but it is possible to target a specific output with a prefix. The fo prefix affects the PDF output and the html targets the HTML content. More details about docbook images parameterization can be found in the docbook imagedata reference.
Table 2.16. Admonitions
Note | {{note}}Some noticeable text{{/note}} | Notesome noticeable text |
Warning | {{warning}}you should not do that{{/warning}} | Warningyou should not do that |
Tip | {{tip}}a usefull tip{{/tip}} | Tipa usefull tip |
Caution | {{caution}}beware!!!{{/caution}} | Cautionbeware!!! |
Important | {{important}}something important{{/important}} | Importantsomething important |
A set of special blocks are available, they allow to give a special representation to the emboddied text.
The code macro creates a docbook programlisting XML element to display anything related to code. Special features are available that makes it very powerful
Table 2.19. XML pretty printted
{{code language=xml indent=2}}<valid><formatted/></valid>{{/code}} |
<valid> <formatted/> </valid> |
The screen macro creates a docbook screen XML element to display anything related to the computer screen:
Table 2.20. A screen example
{{screen}} julien:core julien$ ls -l total 24 -rw-r--r-- 1 julien staff 1878 Apr 26 15:08 pom.xml drwxr-xr-x 5 julien staff 170 Apr 26 15:08 src drwxr-xr-x 5 julien staff 170 Apr 26 18:46 target -rw-r--r-- 1 julien staff 4090 Apr 26 15:09 wikbook.core.iml {{/screen}} |
julien:core julien$ ls -l total 24 -rw-r--r-- 1 julien staff 1878 Apr 26 15:08 pom.xml drwxr-xr-x 5 julien staff 170 Apr 26 15:08 src drwxr-xr-x 5 julien staff 170 Apr 26 18:46 target -rw-r--r-- 1 julien staff 4090 Apr 26 15:09 wikbook.core.iml |
Callouts are useful for creating a set of references that refers to a block of code. At the moment they are only available for Javatm language. A callout is declared inside a code block using comments in special format.
Callout anchor don't have to be mixed with the related text, a simple declaration without any text will just create an anchor. Somewhere else in the code base, the callout text can be declared by adding an equals sign between the right angle bracket and the text. As a consequence, several lines can be referenced with the same callout.
Wiki definition lists are managed as docbook variable lists.
Table 2.23. Definition lists
; term : definition | <variablelist> <varlistentry> <term>term</term> <listitem>definition</listitem> </varlistentry> </variablelist> |
(% title="the title" %) ; term : definition | <variablelist> <title>the title</title> <varlistentry> <term>term</term> <listitem>definition</listitem> </varlistentry> </variablelist> |
The include macro is a good way to provide modularization of a complex document.
Embedding does a special treatment to sections: when a document is embedded, its section are reconsidered with respect to the most inner section embedding the document.
Table of Contents
This chapter focuses on the integration of the documentation with the project it documents.
Wikbook allows to embbed Javatm source code inside the documentation. It is very powerful when it comes to explain a tutorial or to explain an API.
A code catalog is produced by a Java 6 compiler plugin that create source code fragments at the compilation. It is triggered automatically with the Java 6 compiler when the Wikbook APT jar is on the classpath and produce a code catalog within the jar file itself.
Example 3.1. The Wikbook dependency for producing a code catalog
<dependency> <groupId>org.wikbook</groupId> <artifactId>wikbook.apt</artifactId> <version>{{property.wikbook.version}}</version> </dependency>
public class AnObject { }
A code catalog is created from annotated Javatm code when it is annotated with the @org.wikbook.apt.annotation.Documented
annotation. The annotation can target:
todo
The Maven Wikbook plugin converts wiki document to a Docbook document. In order to produce final consumable documents (PDF, HTML), the Docbook document must be converted to new documents, this process is usually done via an XSL stylesheet that takes the Docbook document and transforms it. The Maven jdocbook plugin is a nice integration of the XSL stylesheet transformation with Maven. We recommand to use the Maven Wikbook and jdocbook plugin altogether.