• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2<html>
3<head>
4<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5<title>Documenting libraries</title>
6<link rel="stylesheet" href="../../../doc/src/boostbook.css" type="text/css">
7<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
8<link rel="home" href="../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset">
9<link rel="up" href="../boostbook.html" title="Chapter 49. The BoostBook Documentation Format">
10<link rel="prev" href="getting/started.html" title="Getting Started">
11<link rel="next" href="together.html" title="Bringing Together a BoostBook Document">
12</head>
13<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
14<table cellpadding="2" width="100%"><tr>
15<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../boost.png"></td>
16<td align="center"><a href="../../../index.html">Home</a></td>
17<td align="center"><a href="../../../libs/libraries.htm">Libraries</a></td>
18<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
19<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
20<td align="center"><a href="../../../more/index.htm">More</a></td>
21</tr></table>
22<hr>
23<div class="spirit-nav">
24<a accesskey="p" href="getting/started.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../boostbook.html"><img src="../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="together.html"><img src="../../../doc/src/images/next.png" alt="Next"></a>
25</div>
26<div class="section">
27<div class="titlepage"><div><div><h2 class="title" style="clear: both">
28<a name="boostbook.documenting"></a>Documenting libraries</h2></div></div></div>
29<div class="toc"><dl class="toc">
30<dt><span class="section"><a href="documenting.html#boostbook.defining">Defining a BoostBook library</a></span></dt>
31<dt><span class="section"><a href="documenting.html#id-1.4.3.5.4">From HTML to BoostBook</a></span></dt>
32<dt><span class="section"><a href="documenting.html#boostbook.sectioning">Sectioning in BoostBook</a></span></dt>
33</dl></div>
34<p>BoostBook is an extension to <a href="http://www.docbook.org" target="_top">DocBook</a>, an XML format for
35  representing documentation. BoostBook inherits much of its
36  functionality and many elements from DocBook that are not
37  redocumented here. When writing BoostBook documentation, please
38  refer also to <a href="http://docbook.org/tdg/en/index.html" target="_top">DocBook: The Definitive
39  Guide</a>.</p>
40<div class="section">
41<div class="titlepage"><div><div><h3 class="title">
42<a name="boostbook.defining"></a>Defining a BoostBook library</h3></div></div></div>
43<p>BoostBook library documentation is contained entirely within
44    a &lt;library&gt; XML element. To create a skeletal library, we
45    need to create a new XML document (call it <code class="computeroutput">any.xml</code>)
46    that contains basic information about the library. The following
47    <a class="link" href="documenting.html#boostbook.documenting.skeletal" title="Example 49.1. A Skeletal BoostBook Library">BoostBook XML
48    example</a> describes basic information about the <a href="http://www.boost.org/libs/any/index.html" target="_top">Boost.Any</a>
49    library:</p>
50<div class="example">
51<a name="boostbook.documenting.skeletal"></a><p class="title"><b>Example 49.1. A Skeletal BoostBook Library</b></p>
52<div class="example-contents"><pre class="programlisting">
53&lt;?xml version="1.0" encoding="utf-8"?&gt;
54&lt;!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
55  "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd"&gt;
56&lt;library name="Any" dirname="any" xmlns:xi="http://www.w3.org/2001/XInclude"
57  id="any" last-revision="$Date$"&gt;
58  &lt;libraryinfo&gt;
59    &lt;author&gt;
60      &lt;firstname&gt;Kevlin&lt;/firstname&gt;
61      &lt;surname&gt;Henney&lt;/surname&gt;
62    &lt;/author&gt;
63    &lt;librarypurpose&gt;
64      Safe, generic container for single values of different value types
65    &lt;/librarypurpose&gt;
66    &lt;librarycategory name="category:data-structures"/&gt;
67  &lt;/libraryinfo&gt;
68&lt;/library&gt;
69</pre></div>
70</div>
71<br class="example-break"><p>The first three lines identify this document as a BoostBook
72    <a href="http://www.w3.org/XML/" target="_top">XML</a> document. The
73    DOCTYPE line states that the document conforms to the BoostBook
74    DTD, and that the top-level element is a BoostBook
75    &lt;library&gt;.</p>
76<p>The &lt;library&gt; element actually describes the aspects
77    of BoostBook library documentation. The attributes for the
78    &lt;library&gt; element are:</p>
79<div class="variablelist">
80<p class="title"><b>Attributes for the &lt;library&gt; element</b></p>
81<dl class="variablelist">
82<dt><span class="term"><code class="computeroutput">name</code></span></dt>
83<dd>The full name of the library, e.g., "Any"</dd>
84<dt><span class="term"><code class="computeroutput">dirname</code></span></dt>
85<dd>The name of the directory, relative to
86            <code class="computeroutput">boost/libs</code>, in which the library
87            resides. This name may be a relative path, such as
88            <code class="computeroutput">math/octonion</code>, using "/" for the directory
89            separator.</dd>
90<dt><span class="term"><code class="computeroutput">id</code></span></dt>
91<dd>A short, unique name for the library. For libraries
92          with simple directory names (e.g., ones that do not contain
93          a "/"), this should be the same as the
94          <code class="computeroutput">dirname</code>. This <code class="computeroutput">id</code> will be used to
95          identify libraries and, for HTML output, will be used as the
96          base name for the HTML file in which the library's
97          documentation resides, so it should use only lowercase
98          alphanumeric characters and underscores.</dd>
99<dt><span class="term"><code class="computeroutput">last-revision</code></span></dt>
100<dd>Always set to <code class="computeroutput">$Date$</code>, which is
101          expanded by CVS to include the date and time that the file
102          was last modified.</dd>
103</dl>
104</div>
105<p>Inside the &lt;library&gt; element we have the
106    &lt;libraryinfo&gt; element, which gives information about the
107    library itself. It contains the author's name (there may be more
108    than one &lt;author&gt; element), followed by the purpose of the
109    library and the list of categorizations. The
110    &lt;librarypurpose&gt; element should always contain a very short
111    (single sentence) description of the library's purpose, and should
112    <span class="emphasis"><em>not</em></span> terminate with a period.</p>
113<p>The list of categories is specified by a set of
114    &lt;librarycategory&gt; elements. Each &lt;librarycategory&gt;
115    element has a <code class="computeroutput">name</code> element that identifies one of the
116    categories. The actual list of categories is in the file
117    <code class="filename">doc/src/boost.xml</code>.
118    </p>
119<p>At this point, we can apply the BoostBook XSL stylesheets to
120    <code class="computeroutput">any.xml</code> (to DocBook) followed by a DocBook XSL
121    stylesheet to generate HTML output, as described in <a class="xref" href="getting/started.html" title="Getting Started">the section called “Getting Started”</a>.</p>
122</div>
123<div class="section">
124<div class="titlepage"><div><div><h3 class="title">
125<a name="id-1.4.3.5.4"></a>From HTML to BoostBook</h3></div></div></div>
126<p>Most library authors are comfortable with writing HTML
127    documentation. Writing <a href="http://www.docbook.org" target="_top">DocBook</a> documentation (and,
128    by extension, BoostBook documentation) is quite similar to writing
129    HTML, except that BoostBook uses different element names from HTML
130    (see <a class="xref" href="documenting.html#html.to.boostbook" title="Table 49.2. Converting HTML elements to BoostBook">Table 49.2, “Converting HTML elements to BoostBook”</a>) and BoostBook XML is a
131    much more rigid format than HTML.</p>
132<p>One of the easiest ways to convert HTML documentation into
133    BoostBook documentation is to use <a href="http://tidy.sourceforge.net/" target="_top">HTML Tidy</a> to transform
134    your HTML into valid XHTML, which will make sure that all elements
135    are properly closed, then apply the transformations in <a class="xref" href="documenting.html#html.to.boostbook" title="Table 49.2. Converting HTML elements to BoostBook">Table 49.2, “Converting HTML elements to BoostBook”</a> to the body of the XHTML
136    document. The following command uses HTML Tidy to transform HTML
137    into valid XHTML:</p>
138<pre class="programlisting">
139  tidy -asxhtml input.html &gt; output.xhtml</pre>
140<p>When converting documentation from HTML to BoostBook, note
141    that some redundant information that has to be manually maintained
142    in HTML is automatically generated in BoostBook: for instance, the
143    library categorizations, purpose, and author list described in
144    <a class="xref" href="documenting.html#boostbook.defining" title="Defining a BoostBook library">the section called “Defining a BoostBook library”</a> are used both in the
145    documentation for the library and to build alphabetical and
146    categorized lists of known libraries; similarly, tables of
147    contents are built automatically from the titles of sections in
148    the BoostBook document.</p>
149<div class="table">
150<a name="html.to.boostbook"></a><p class="title"><b>Table 49.2. Converting HTML elements to BoostBook</b></p>
151<div class="table-contents"><table class="table" summary="Converting HTML elements to BoostBook">
152<colgroup>
153<col>
154<col>
155</colgroup>
156<thead><tr>
157<th align="left">HTML</th>
158<th align="left">BoostBook</th>
159</tr></thead>
160<tbody>
161<tr>
162<td align="left"><p>&lt;h1&gt;, &lt;h2&gt;, etc.</p></td>
163<td align="left">
164<p>&lt;section&gt;, &lt;title&gt;; See <a class="xref" href="documenting.html#boostbook.sectioning" title="Sectioning in BoostBook">the section called “Sectioning in BoostBook”</a></p>
165</td>
166</tr>
167<tr>
168<td align="left"><p>&lt;i&gt;, &lt;em&gt;</p></td>
169<td align="left"><p>&lt;emphasis&gt;</p></td>
170</tr>
171<tr>
172<td align="left"><p>&lt;b&gt;</p></td>
173<td align="left"><p>&lt;emphasis role="bold"&gt;</p></td>
174</tr>
175<tr>
176<td align="left"><p>&lt;ol&gt;</p></td>
177<td align="left"><p>&lt;orderedlist&gt;</p></td>
178</tr>
179<tr>
180<td align="left"><p>&lt;ul&gt;</p></td>
181<td align="left"><p>&lt;itemizedlist&gt;</p></td>
182</tr>
183<tr>
184<td align="left"><p>&lt;li&gt;</p></td>
185<td align="left"><p>&lt;listitem&gt;</p></td>
186</tr>
187<tr>
188<td align="left"><p>&lt;pre&gt;</p></td>
189<td align="left"><p>&lt;programlisting&gt;</p></td>
190</tr>
191<tr>
192<td align="left"><p>&lt;code&gt;</p></td>
193<td align="left"><p>&lt;computeroutput&gt;,&lt;code&gt;</p></td>
194</tr>
195<tr>
196<td align="left"><p>&lt;p&gt;</p></td>
197<td align="left"><p>&lt;para&gt;, &lt;simpara&gt;</p></td>
198</tr>
199<tr>
200<td align="left"><p>&lt;a&gt;</p></td>
201<td align="left">
202<p>&lt;xref&gt;, &lt;link&gt;, &lt;ulink&gt;;, See <a class="xref" href="together.html#boostbook.linking" title="Linking in BoostBook">the section called “Linking in BoostBook”</a></p>
203</td>
204</tr>
205<tr>
206<td align="left"><p>&lt;table&gt;, &lt;tr&gt;, &lt;th&gt;, &lt;td&gt;</p></td>
207<td align="left"><p>&lt;table&gt;, &lt;informaltable&gt;, &lt;tgroup&gt;, &lt;thead&gt;, &lt;tfoot&gt;, &lt;tbody&gt;, &lt;row&gt;, &lt;entry&gt;, &lt;entrytbl&gt;; BoostBook tables are equivalent to DocBook tables, for which there is a good <a href="http://opensource.bureau-cornavin.com/crash-course/en/tables.html" target="_top">tutorial here</a></p></td>
208</tr>
209</tbody>
210</table></div>
211</div>
212<br class="table-break">
213</div>
214<div class="section">
215<div class="titlepage"><div><div><h3 class="title">
216<a name="boostbook.sectioning"></a>Sectioning in BoostBook</h3></div></div></div>
217<p>"Sectioning" refers to organization of a document into separate sections, each with a title, some text, and possibly subsections. Each section is described in BoostBook via a &lt;section&gt; element. An introduction section may look like this:</p>
218<pre class="programlisting">
219&lt;section id="any.intro"&gt;
220  &lt;title&gt;Introduction&lt;/title&gt;
221
222  &lt;para&gt;Introduction to a library...&lt;/para&gt;
223
224  &lt;section&gt;
225    &lt;title&gt;A Subsection&lt;/title&gt;
226    &lt;para&gt;Subsection information...&lt;/para&gt;
227  &lt;/section&gt;
228&lt;/section&gt;
229</pre>
230<p>The &lt;section&gt; element contains all information that
231    should logically be grouped within that section. The title of the
232    section is placed within the &lt;title&gt; element, and any
233    paragraphs, programs, lists, tables, or subsections can occur
234    within the section. The <code class="computeroutput">id</code> attribute of the
235    &lt;section&gt; element gives a unique ID to each section, so that
236    it may later be identified for linking. It is suggested that all
237    IDs start with the short name of a library followed by a period,
238    so that IDs do not conflict between libraries.</p>
239</div>
240</div>
241<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
242<td align="left"></td>
243<td align="right"><div class="copyright-footer">Copyright © 2003-2005 Douglas Gregor<p>Distributed under the Boost Software License, Version 1.0.
244      (See accompanying file LICENSE_1_0.txt or copy at
245      <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>).
246      </p>
247</div></td>
248</tr></table>
249<hr>
250<div class="spirit-nav">
251<a accesskey="p" href="getting/started.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../boostbook.html"><img src="../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="together.html"><img src="../../../doc/src/images/next.png" alt="Next"></a>
252</div>
253</body>
254</html>
255