mirror of
https://github.com/boostorg/boostbook.git
synced 2025-05-09 15:03:57 +00:00
BoostBook documentation
[SVN r17863]
This commit is contained in:
parent
df433e64bd
commit
5c62149ef7
222
doc/boostbook.xml
Normal file
222
doc/boostbook.xml
Normal file
@ -0,0 +1,222 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!DOCTYPE chapter SYSTEM "../../dtd/boostbook.dtd">
|
||||||
|
<chapter xmlns:xi="http://www.w3.org/2001/XInclude" id="boostbook">
|
||||||
|
<chapterinfo>
|
||||||
|
<author>
|
||||||
|
<firstname>Douglas</firstname>
|
||||||
|
<surname>Gregor</surname>
|
||||||
|
</author>
|
||||||
|
|
||||||
|
<copyright>
|
||||||
|
<year>2003</year>
|
||||||
|
<holder>Douglas Gregor</holder>
|
||||||
|
</copyright>
|
||||||
|
|
||||||
|
<legalnotice>
|
||||||
|
<para>Permission to copy, use, sell and distribute this software
|
||||||
|
is granted provided this copyright notice appears in all copies.
|
||||||
|
Permission to modify the code and to distribute modified code is
|
||||||
|
granted provided this copyright notice appears in all copies,
|
||||||
|
and a notice that the code was modified is included with the
|
||||||
|
copyright notice. </para>
|
||||||
|
|
||||||
|
<para> This software is provided "as is" without express or
|
||||||
|
implied warranty, and with no claim as to its suitability for
|
||||||
|
any purpose. </para>
|
||||||
|
</legalnotice>
|
||||||
|
</chapterinfo>
|
||||||
|
|
||||||
|
<title>The BoostBook Documentation Format</title>
|
||||||
|
|
||||||
|
<section>
|
||||||
|
<title>Introduction</title>
|
||||||
|
|
||||||
|
<para>The BoostBook documentation format is an extension of <ulink
|
||||||
|
url="http://www.docbook.org">DocBook</ulink>, an SGML- or
|
||||||
|
XML-based format for describing documentation. BoostBook augments
|
||||||
|
DocBook with semantic markup that aids in the documentation of C++
|
||||||
|
libraries, specifically the <ulink
|
||||||
|
url="http://www.boost.org">Boost C++ libraries</ulink>, by
|
||||||
|
providing the ability to express and refer to C++ constructs such
|
||||||
|
as namespaces, classes, overloaded functions, templates, and
|
||||||
|
specializations.</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
BoostBook offers additional features more specific to its use for
|
||||||
|
documenting the <ulink url="http://www.boost.org">Boost C++
|
||||||
|
libraries</ulink>. These features are intended to eliminate or
|
||||||
|
reduce the need for duplication of information and to aid in
|
||||||
|
documenting portions of Boost that might otherwise not be
|
||||||
|
documented. Examples of Boost-centric features include:
|
||||||
|
<itemizedlist>
|
||||||
|
<listitem>
|
||||||
|
<para><emphasis role="bold">Testsuites</emphasis>:
|
||||||
|
Testsuites in Boost are created by writing an appropriate
|
||||||
|
Jamfile and including that Jamfile in the list of Jamfiles
|
||||||
|
including for testing. If the testsuites are documented
|
||||||
|
(<ulink
|
||||||
|
url="http://www.boost.org/libs/multi_array/doc/test_cases.html">as
|
||||||
|
in the MultiArray library</ulink>), the documentation is
|
||||||
|
maintained separately from the testcase Jamfile, leading to
|
||||||
|
duplication of information and the possibility of having the
|
||||||
|
documentation out of sync with the Jamfile. BoostBook
|
||||||
|
contains elements that describe a testsuite for both
|
||||||
|
purposes: the BoostBook stylesheets can generate
|
||||||
|
documentation for the testcases and also generate an
|
||||||
|
appropriate Jamfile to integrate the testcases with the
|
||||||
|
regression testing system.</para>
|
||||||
|
</listitem>
|
||||||
|
<listitem>
|
||||||
|
<para><emphasis role="bold">Example programs</emphasis>:
|
||||||
|
Example programs in documentation need to be duplicated in
|
||||||
|
testcases to ensure that the examples compile and execute
|
||||||
|
correctly. Keeping the two copies in sync is a tedious and
|
||||||
|
error-prone task. For instance, the following code snippet
|
||||||
|
persisted for six months:</para>
|
||||||
|
<programlisting>
|
||||||
|
std::cout << f(5, 3) >> std::endl;
|
||||||
|
</programlisting>
|
||||||
|
<para>The BoostBook format allows testcases to be generated
|
||||||
|
by weaving together program fragments from example programs
|
||||||
|
in the documentation. This capability is integrated with
|
||||||
|
testsuite generation so that example programs are normal
|
||||||
|
tests in BoostBook.</para>
|
||||||
|
</listitem>
|
||||||
|
<listitem>
|
||||||
|
<para><emphasis role="bold">Library
|
||||||
|
categorization</emphasis>: BoostBook contains primitives for
|
||||||
|
placing libraries into categories and generating categorized
|
||||||
|
and alphabetized lists of libraries.</para>
|
||||||
|
</listitem>
|
||||||
|
</itemizedlist>
|
||||||
|
</para>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section id="boostbook.getting.started">
|
||||||
|
<title>Getting Started</title>
|
||||||
|
|
||||||
|
<para>To use the Boost documentation tools, you will need an
|
||||||
|
<ulink url="http://www.w3c.org/Style/XSL/">XSLT</ulink>
|
||||||
|
processor. There are many XSLT processors available, but for now
|
||||||
|
we suggest that you use <code>xsltproc</code>, part of <ulink
|
||||||
|
url="http://xmlsoft.org/XSLT/">libxslt</ulink>. There are several
|
||||||
|
ways to get libxslt, depending on your platform:</para>
|
||||||
|
|
||||||
|
<itemizedlist>
|
||||||
|
<listitem>
|
||||||
|
<para>On Unix: Build and install <ulink
|
||||||
|
url="http://xmlsoft.org/">libxml2</ulink>) and then <ulink
|
||||||
|
url="http://xmlsoft.org/XSLT/">libxslt</ulink>)</para>
|
||||||
|
</listitem>
|
||||||
|
<listitem>
|
||||||
|
<para>On Windows:</para>
|
||||||
|
|
||||||
|
<itemizedlist>
|
||||||
|
<listitem>
|
||||||
|
<para>With <ulink
|
||||||
|
url="http://www.cygwin.com/">Cygwin</ulink>, select the
|
||||||
|
libxml2 and libxslt packages</para>
|
||||||
|
</listitem>
|
||||||
|
<listitem>
|
||||||
|
<para>Without Cygwin, you can at <ulink
|
||||||
|
url="http://www.zlatkovic.com/projects/libxml/binaries.html">download
|
||||||
|
the libxml2, libxslt, and iconv binaries</ulink>. Or, use
|
||||||
|
my <ulink
|
||||||
|
url="http://www.cs.rpi.edu/~gregod/boost/doc/xsltproc-win32.zip">minimal
|
||||||
|
repackaged version</ulink>.</para>
|
||||||
|
</listitem>
|
||||||
|
</itemizedlist>
|
||||||
|
</listitem>
|
||||||
|
</itemizedlist>
|
||||||
|
|
||||||
|
<para>You will also need a recent checkout of Boost from <ulink
|
||||||
|
url="http://www.boost.org/more/download.html#CVS">CVS</ulink> and
|
||||||
|
a very recent checkout from the <ulink
|
||||||
|
url="http://www.boost.org/more/mailing_lists.htm#sandbox">Boost
|
||||||
|
Sandbox CVS</ulink>. Finally, you will need Norman Walsh's DocBook
|
||||||
|
XSL stylesheets, available at the (<ulink
|
||||||
|
url="http://docbook.sourceforge.net">DocBook sourceforge
|
||||||
|
site</ulink>. Extract the DocBook XSL stylesheets to a directory
|
||||||
|
on your hard disk (which we'll refer to as the
|
||||||
|
<code>DOCBOOK_XSL_PATH</code>).</para>
|
||||||
|
|
||||||
|
<para>The current BoostBook documentation encompasses only a few
|
||||||
|
libraries. The documentation for these libraries is stored in the
|
||||||
|
directory
|
||||||
|
<code>boost-sandbox/libs/documentation/examples</code>. From that
|
||||||
|
directory, we can generate DocBook XML from the BoostBook XML by
|
||||||
|
invoking <code>xsltproc</code>:</para>
|
||||||
|
|
||||||
|
<programlisting>
|
||||||
|
xsltproc --xinclude ../boostbook-xsl/docbook.xsl boost.xml > boost.docbook
|
||||||
|
</programlisting>
|
||||||
|
|
||||||
|
<para>This command parses the BoostBook XML in the file
|
||||||
|
<code>boost.xml</code>, using <ulink
|
||||||
|
url="http://www.w3.org/TR/xinclude/">XIncludes</ulink> to bring in
|
||||||
|
other library documentation (e.g.,
|
||||||
|
<code>function/function.xml</code> for the Function library), and
|
||||||
|
then translates the XML via the XSL stylesheet docbook.xsl into
|
||||||
|
DocBook XML, which is written to <code>boost.docbook</code>. You
|
||||||
|
will probably see several warnings like these while
|
||||||
|
<code>xsltproc</code> executes:</para>
|
||||||
|
|
||||||
|
<programlisting>
|
||||||
|
Cannot find function named 'checked_delete'
|
||||||
|
Cannot find function named 'checked_array_delete'
|
||||||
|
Cannot find function named 'next'
|
||||||
|
</programlisting>
|
||||||
|
|
||||||
|
<para>These warnings are emitted when the Boost documentation
|
||||||
|
tools cannot find documentation for functions, methods, or classes
|
||||||
|
that are referenced in the source, and are not harmful in any
|
||||||
|
way.</para>
|
||||||
|
|
||||||
|
<para>With DocBook XML, we can generate several other
|
||||||
|
documentation formats. To generate HTML, we invoke xsltproc to
|
||||||
|
transform the DocBook XML into HTML with the following command
|
||||||
|
(replace <code><html-output-dir></code> with a directory of your
|
||||||
|
choice):</para>
|
||||||
|
|
||||||
|
<programlisting>
|
||||||
|
xsltproc -o <html-output-dir> <DOCBOOK_XSL_PATH>/html/chunk.xsl boost.docbook
|
||||||
|
</programlisting>
|
||||||
|
|
||||||
|
<para>Once this command completes, you will have HTML
|
||||||
|
documentation. There are many options that can be used to
|
||||||
|
customize the output HTML; please see the Makefile for the set of
|
||||||
|
commands used to generate the <ulink
|
||||||
|
url="http://www.cs.rpi.edu/~gregod/boost/doc/html/libraries.html">nightly
|
||||||
|
documentation</ulink>.</para>
|
||||||
|
|
||||||
|
<para>The DocBook XSL stylesheets support other output formats,
|
||||||
|
such as Unix man pages, XHTML, HTML as a single file, and XSL
|
||||||
|
Formatting Objects (which can in turn be used to generate, e.g.,
|
||||||
|
PDF or PostScript documentation). To generate these other formats,
|
||||||
|
please refer to the <ulink
|
||||||
|
url="http://docbook.sourceforge.net">DocBook XSL stylesheets
|
||||||
|
documentation</ulink>.</para>
|
||||||
|
|
||||||
|
<para>For users of Unix-based systems, the Makefile supplied in
|
||||||
|
the <code>examples/</code> directory can help generate DocBook,
|
||||||
|
HTML, man pages, and FO. To generate the necessary files
|
||||||
|
(<code>Makefile.def</code> and <code>catalog.xml</code>),
|
||||||
|
invoke:</para>
|
||||||
|
|
||||||
|
<programlisting>
|
||||||
|
./configure DOCBOOK_XSL_PATH
|
||||||
|
</programlisting>
|
||||||
|
|
||||||
|
<para>Now run any of:</para>
|
||||||
|
<programlisting>
|
||||||
|
make html
|
||||||
|
make fo
|
||||||
|
make man
|
||||||
|
make docbook
|
||||||
|
</programlisting>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<xi:include href="documenting.xml"/>
|
||||||
|
<xi:include href="reference_doc.xml"/>
|
||||||
|
<xi:include href="together.xml"/>
|
||||||
|
</chapter>
|
237
doc/documenting.xml
Normal file
237
doc/documenting.xml
Normal file
@ -0,0 +1,237 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!DOCTYPE section SYSTEM "../../dtd/boostbook.dtd">
|
||||||
|
<section xmlns:xi="http://www.w3.org/2001/XInclude">
|
||||||
|
<title>Documenting libraries</title>
|
||||||
|
|
||||||
|
<para>BoostBook is an extension to <ulink
|
||||||
|
url="http://www.docbook.org">DocBook</ulink>, an XML format for
|
||||||
|
representing documentation. BoostBook inherits much of its
|
||||||
|
functionality and many elements from DocBook that are not
|
||||||
|
redocumented here. When writing BoostBook documentation, please
|
||||||
|
refer also to <ulink
|
||||||
|
url="http://docbook.org/tdg/en/index.html">DocBook: The Definitive
|
||||||
|
Guide</ulink>.</para>
|
||||||
|
|
||||||
|
<section id="boostbook.defining">
|
||||||
|
<title>Defining a BoostBook library</title>
|
||||||
|
|
||||||
|
<para>BoostBook library documentation is contained entirely within
|
||||||
|
a <library> XML element. To create a skeletal library, we
|
||||||
|
need to create a new XML document (call it <code>any.xml</code>)
|
||||||
|
that contains basic information about the library. The following
|
||||||
|
<link linkend="boostbook.documenting.skeletal">BoostBook XML
|
||||||
|
example</link> describes basic information about the <ulink
|
||||||
|
url="http://www.boost.org/libs/any/index.html">Boost.Any</ulink>
|
||||||
|
library:</para>
|
||||||
|
|
||||||
|
<example id="boostbook.documenting.skeletal">
|
||||||
|
<title>A Skeletal BoostBook Library</title>
|
||||||
|
<programlisting>
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!DOCTYPE library SYSTEM "../../dtd/boostbook.dtd">
|
||||||
|
<library name="Any" dirname="any" xmlns:xi="http://www.w3.org/2001/XInclude" id="any">
|
||||||
|
<libraryinfo>
|
||||||
|
<author>
|
||||||
|
<firstname>Kevlin</firstname>
|
||||||
|
<surname>Henney</surname>
|
||||||
|
</author>
|
||||||
|
<librarypurpose>
|
||||||
|
Safe, generic container for single values of different value types
|
||||||
|
</librarypurpose>
|
||||||
|
<librarycategory name="category:data-structures"/>
|
||||||
|
</libraryinfo>
|
||||||
|
</library>
|
||||||
|
</programlisting>
|
||||||
|
</example>
|
||||||
|
|
||||||
|
<para>The first two lines identify this document as a BoostBook
|
||||||
|
<ulink url="http://www.w3.org/XML/">XML</ulink> document. The
|
||||||
|
DOCTYPE line states that the document conforms to the BoostBook
|
||||||
|
DTD (here accessed via the relative path
|
||||||
|
<code>../../dtd/boostbook.dtd</code>, though this path may change
|
||||||
|
depending on the location of <code>any.xml</code>) and that the
|
||||||
|
top-level element is a BoostBook <library>.</para>
|
||||||
|
|
||||||
|
<para>The <library> element actually describes the aspects
|
||||||
|
of BoostBook library documentation. The attributes for the
|
||||||
|
<library> element are:</para>
|
||||||
|
|
||||||
|
<variablelist>
|
||||||
|
<title>Attributes for the <library> element</title>
|
||||||
|
<varlistentry>
|
||||||
|
<term><code>name</code></term>
|
||||||
|
<listitem>
|
||||||
|
<simpara>The full name of the library, e.g., "Any"</simpara>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
<varlistentry>
|
||||||
|
<term><code>dirname</code></term>
|
||||||
|
<listitem>
|
||||||
|
<simpara>The name of the directory, relative to
|
||||||
|
<code>boost/libs</code>, in which the library
|
||||||
|
resides. This name may be a relative path, such as
|
||||||
|
<code>math/octonion</code>, using "/" for the directory
|
||||||
|
separator.</simpara>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
<varlistentry>
|
||||||
|
<term><code>id</code></term>
|
||||||
|
<listitem>
|
||||||
|
<simpara>A short, unique name for the library. For libraries
|
||||||
|
with simple directory names (e.g., ones that do not contain
|
||||||
|
a "/"), this should be the same as the
|
||||||
|
<code>dirname</code>. This <code>id</code> will be used to
|
||||||
|
identify libraries and, for HTML output, will be used as the
|
||||||
|
base name for the HTML file in which the library's
|
||||||
|
documentation resides, so it should use only lowercase
|
||||||
|
alphanumeric characters and underscores.</simpara>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
</variablelist>
|
||||||
|
|
||||||
|
<para>Inside the <library> element we have the
|
||||||
|
<libraryinfo> element, which gives information about the
|
||||||
|
library itself. It contains the author's name (there may be more
|
||||||
|
than one <author> element), followed by the purpose of the
|
||||||
|
library and the list of categorizations. The
|
||||||
|
<librarypurpose> element should always contain a very short
|
||||||
|
(single sentence) description of the library's purpose, and should
|
||||||
|
<emphasis>not</emphasis> terminate with a period.</para>
|
||||||
|
|
||||||
|
<para>The list of categories is specified by a set of
|
||||||
|
<librarycategory> elements. Each <librarycategory>
|
||||||
|
element has a <code>name</code> element that identifies one of the
|
||||||
|
categories. The actual list of categories is in the file
|
||||||
|
<filename>boost-sandbox/libs/documentation/examples/boost.xml</filename>.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<para>At this point, we can apply the BoostBook XSL stylesheets to
|
||||||
|
<code>any.xml</code> (to DocBook) followed by a DocBook XSL
|
||||||
|
stylesheet to generate HTML output, as described in <xref
|
||||||
|
linkend="boostbook.getting.started"/>.</para>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section>
|
||||||
|
<title>From HTML to BoostBook</title>
|
||||||
|
|
||||||
|
<para>Most library authors are comfortable with writing HTML
|
||||||
|
documentation. Writing <ulink
|
||||||
|
url="http://www.docbook.org">DocBook</ulink> documentation (and,
|
||||||
|
by extension, BoostBook documentation) is quite similar to writing
|
||||||
|
HTML, except that BoostBook uses different element names from HTML
|
||||||
|
(see <xref linkend="html.to.boostbook"/>) and BoostBook XML is a
|
||||||
|
much more rigid format than HTML.</para>
|
||||||
|
|
||||||
|
<para>One of the easiest ways to convert HTML documentation into
|
||||||
|
BoostBook documentation is to use <ulink
|
||||||
|
url="http://tidy.sourceforge.net/">HTML Tidy</ulink> to transform
|
||||||
|
your HTML into valid XHTML, which will make sure that all elements
|
||||||
|
are properly closed, then apply the transformations in <xref
|
||||||
|
linkend="html.to.boostbook"/> to the body of the XHTML
|
||||||
|
document. The following command uses HTML Tidy to transform HTML
|
||||||
|
into valid XHTML:</para>
|
||||||
|
|
||||||
|
<programlisting>
|
||||||
|
tidy -asxhtml input.html > output.xhtml</programlisting>
|
||||||
|
|
||||||
|
<para>When converting documentation from HTML to BoostBook, note
|
||||||
|
that some redundant information that has to be manually maintained
|
||||||
|
in HTML is automatically generated in BoostBook: for instance, the
|
||||||
|
library categorizations, purpose, and author list described in
|
||||||
|
<xref linkend="boostbook.defining"/> are used both in the
|
||||||
|
documentation for the library and to build alphabetical and
|
||||||
|
categorized lists of known libraries; similarly, tables of
|
||||||
|
contents are built automatically from the titles of sections in
|
||||||
|
the BoostBook document.</para>
|
||||||
|
|
||||||
|
<table id="html.to.boostbook">
|
||||||
|
<title>Converting HTML elements to BoostBook</title>
|
||||||
|
<tgroup cols="2" align="left">
|
||||||
|
<thead>
|
||||||
|
<row>
|
||||||
|
<entry>HTML</entry>
|
||||||
|
<entry>BoostBook</entry>
|
||||||
|
</row>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<row>
|
||||||
|
<entry><simpara><h1>, <h2>, etc.</simpara></entry>
|
||||||
|
<entry>
|
||||||
|
<simpara><section>, <title>; See <xref
|
||||||
|
linkend="boostbook.sectioning"/></simpara>
|
||||||
|
</entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><simpara><i>, <em></simpara></entry>
|
||||||
|
<entry><simpara><emphasis></simpara></entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><simpara><b></simpara></entry>
|
||||||
|
<entry><simpara><emphasis role="bold"></simpara></entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><simpara><ol></simpara></entry>
|
||||||
|
<entry><simpara><orderedlist></simpara></entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><simpara><ul></simpara></entry>
|
||||||
|
<entry><simpara><itemizedlist></simpara></entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><simpara><li></simpara></entry>
|
||||||
|
<entry><simpara><listitem></simpara></entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><simpara><pre></simpara></entry>
|
||||||
|
<entry><simpara><programlisting></simpara></entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><simpara><code></simpara></entry>
|
||||||
|
<entry><simpara><computeroutput>,<code></simpara></entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><simpara><p></simpara></entry>
|
||||||
|
<entry><simpara><para>, <simpara></simpara></entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><simpara><a></simpara></entry>
|
||||||
|
<entry>
|
||||||
|
<simpara><xref>, <link>, <ulink>;, See <xref
|
||||||
|
linkend="boostbook.linking"/></simpara></entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><simpara><table>, <tr>, <th>, <td></simpara></entry>
|
||||||
|
<entry><simpara><table>, <informaltable>, <tgroup>, <thead>, <tfoot>, <tbody>, <row>, <entry>, <entrytbl>; BoostBook tables are equivalent to DocBook tables, for which there is a good <ulink url="http://opensource.bureau-cornavin.com/crash-course/tables.html">tutorial here</ulink></simpara></entry>
|
||||||
|
</row>
|
||||||
|
</tbody>
|
||||||
|
</tgroup>
|
||||||
|
</table>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section id="boostbook.sectioning">
|
||||||
|
<title>Sectioning in BoostBook</title>
|
||||||
|
<para>"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 <section> element. An introduction section may look like this:</para>
|
||||||
|
<programlisting>
|
||||||
|
<section id="any.intro">
|
||||||
|
<title>Introduction</title>
|
||||||
|
|
||||||
|
<para>Introduction to a library...</para>
|
||||||
|
|
||||||
|
<section>
|
||||||
|
<title>A Subsection</title>
|
||||||
|
<para>Subsection information...</para>
|
||||||
|
</section>
|
||||||
|
</section>
|
||||||
|
</programlisting>
|
||||||
|
<para>The <section> element contains all information that
|
||||||
|
should logically be grouped within that section. The title of the
|
||||||
|
section is placed within the <title> element, and any
|
||||||
|
paragraphs, programs, lists, tables, or subsections can occur
|
||||||
|
within the section. The <code>id</code> attribute of the
|
||||||
|
<section> element gives a unique ID to each section, so that
|
||||||
|
it may later be identified for linking. It is suggested that all
|
||||||
|
IDs start with the short name of a library followed by a period,
|
||||||
|
so that IDs do not conflict between libraries.</para>
|
||||||
|
</section>
|
||||||
|
</section>
|
||||||
|
|
292
doc/reference_doc.xml
Normal file
292
doc/reference_doc.xml
Normal file
@ -0,0 +1,292 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!DOCTYPE section SYSTEM "../../dtd/boostbook.dtd">
|
||||||
|
<section xmlns:xi="http://www.w3.org/2001/XInclude">
|
||||||
|
<title>Documenting C++ Constructs</title>
|
||||||
|
|
||||||
|
<para>This section describes the documentation of C++ constructs
|
||||||
|
within BoostBook. BoostBook provides elements that describe C++
|
||||||
|
classes, functions, namespaces, and other declarative constructs in
|
||||||
|
a presentation-independent manner. From these descriptions, the
|
||||||
|
BoostBook XSL stylesheets generate cross-referenced reference
|
||||||
|
documentation for C++ libraries with a consistent look and
|
||||||
|
feel.</para>
|
||||||
|
|
||||||
|
<section>
|
||||||
|
<title>Library references and headers</title>
|
||||||
|
|
||||||
|
<para>Reference documentation for a library is contained with a
|
||||||
|
<library-reference> element. The <library-reference>
|
||||||
|
element has no attributes, and contains as children only
|
||||||
|
<header> elements.</para>
|
||||||
|
|
||||||
|
<para>The <header> element defines a C++ header file. Within
|
||||||
|
each C++ header file lie the definitions of C++ constructs to be
|
||||||
|
documented. The <code>name</code> attribute of the <header>
|
||||||
|
element gives the name of the header, as one would specify when
|
||||||
|
including the header. For instance, the <library-reference>
|
||||||
|
for the <libraryname>Any</libraryname> library may look like
|
||||||
|
this:</para>
|
||||||
|
|
||||||
|
<programlisting>
|
||||||
|
<library-reference>
|
||||||
|
<header name="boost/any.hpp">
|
||||||
|
<!-- C++ constructs in this header -->
|
||||||
|
</header>
|
||||||
|
</library-reference>
|
||||||
|
</programlisting>
|
||||||
|
|
||||||
|
<para>If the <libraryname>Any</libraryname> library contained
|
||||||
|
multiple headers, we would list them all as children of the
|
||||||
|
<library-reference> element.</para>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section>
|
||||||
|
<title>Namespaces</title>
|
||||||
|
|
||||||
|
<para>BoostBook namespaces are declared via the <namespace>
|
||||||
|
element. As in C++, namespaces can be nested and contain other C++
|
||||||
|
constructs, such as classes or functions. The <code>name</code>
|
||||||
|
attribute of a <namespace> element gives the namespace name
|
||||||
|
(e.g., "boost"). The <libraryname>Any</libraryname> library is
|
||||||
|
defined entirely within namespace boost by:</para>
|
||||||
|
|
||||||
|
<programlisting>
|
||||||
|
<library-reference>
|
||||||
|
<header name="boost/any.hpp">
|
||||||
|
<namespace name="boost">
|
||||||
|
<!-- C++ constructs in the boost namespace -->
|
||||||
|
</namespace>
|
||||||
|
</header>
|
||||||
|
</library-reference>
|
||||||
|
</programlisting>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section id="boostbook.classes">
|
||||||
|
<title>Classes</title>
|
||||||
|
|
||||||
|
<para>C++ classes and class templates are described via the
|
||||||
|
<class> element. Each class has a name (e.g., "any") given
|
||||||
|
by the <code>name</code> attribute, a purpose given by the
|
||||||
|
<purpose> element, documentation, and a set of types,
|
||||||
|
functions, base classes, and data members. Here is a minimal
|
||||||
|
definition of the <classname>boost::any</classname> class:</para>
|
||||||
|
<programlisting>
|
||||||
|
<namespace name="boost">
|
||||||
|
<class name="any">
|
||||||
|
<purpose>
|
||||||
|
A class whose instances can hold instances of any type that satisfies
|
||||||
|
ValueType requirements.
|
||||||
|
</purpose>
|
||||||
|
</class>
|
||||||
|
</namespace>
|
||||||
|
</programlisting>
|
||||||
|
|
||||||
|
<para>Additional class documentation can be contained in
|
||||||
|
<para> elements following the <purpose> element. This
|
||||||
|
documentation will be typeset prior to documentation for specific
|
||||||
|
elements in the class (e.g., constructors or methods).</para>
|
||||||
|
|
||||||
|
<para>Class inheritance is described via the <inherit>
|
||||||
|
element. The <inherit> element requires an
|
||||||
|
<code>access</code> attribute which must be one of
|
||||||
|
<emphasis>public</emphasis>, <emphasis>protected</emphasis>, or
|
||||||
|
<emphasis>private</emphasis>. The content of the <inherited>
|
||||||
|
element in C++ code that names the class inherited, and may
|
||||||
|
contain markup to link to the class. The following description of
|
||||||
|
the class <classname>boost::bad_any_cast</classname> describes
|
||||||
|
public inheritance from the class
|
||||||
|
<classname>std::bad_cast</classname>. It also defines the
|
||||||
|
<purpose> element, which contains a short description of the
|
||||||
|
use of the class.</para>
|
||||||
|
|
||||||
|
<programlisting>
|
||||||
|
<class name="bad_any_cast">
|
||||||
|
<inherit access="public"><classname>std::bad_cast</classname></inherit>
|
||||||
|
<purpose><para>The exception thrown in the event of a failed
|
||||||
|
<functionname>any_cast</functionname> of an
|
||||||
|
<classname>any</classname> value.</para></purpose>
|
||||||
|
</class>
|
||||||
|
</programlisting>
|
||||||
|
|
||||||
|
<para>Information about constructors, methods, and other functions
|
||||||
|
can be found in <xref linkend="boostbook.functions"/>. Note that
|
||||||
|
free functions and free function groups are allowed at class
|
||||||
|
level, and will be documented along with the class, for instance
|
||||||
|
see the documentation of
|
||||||
|
<functionname>boost::any_cast</functionname>.</para>
|
||||||
|
|
||||||
|
<para>Class templates are defined by <class> elements with a
|
||||||
|
<template> child element at the beginning. Templates are
|
||||||
|
discussed <xref linkend="boostbook.templates"/>.</para>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section id="boostbook.functions">
|
||||||
|
<title>Functions</title>
|
||||||
|
|
||||||
|
<para>BoostBook functions are documented by specifying the
|
||||||
|
function's interface (e.g., its C++ signature) and its
|
||||||
|
behavior. Constructors, destructors, member functions, and free
|
||||||
|
functions all use the same documentation method, although the
|
||||||
|
top-level tags differ; <xref linkend="boostbook.function.types"/>
|
||||||
|
gives the elements for each C++ function type.</para>
|
||||||
|
|
||||||
|
<para>The behavior of functions in BoostBook is documenting using
|
||||||
|
a style similar to that of the C++ standard, with clauses
|
||||||
|
describing the requirements, effects, postconditions, exception
|
||||||
|
behavior, and return values of functions. The names and uses of
|
||||||
|
the XML elements for each clause type are given in <xref
|
||||||
|
linkend="boostbook.function.clauses"/>.</para>
|
||||||
|
|
||||||
|
<para>The following example illustrates some constructors and a
|
||||||
|
destructor for <classname>boost::any</classname>. We note that in
|
||||||
|
each of the clauses from <xref
|
||||||
|
linkend="boostbook.function.clauses"/> there is a (required!)
|
||||||
|
<simpara> element containing the text for that clause. We
|
||||||
|
also note that one of the constructors takes a single parameter
|
||||||
|
whose name is "other" and whose type, <code>const any&</code>
|
||||||
|
is contained in the <paramtype> element; any number of
|
||||||
|
parameters may be specified in this way.</para>
|
||||||
|
|
||||||
|
<programlisting>
|
||||||
|
<class name="any">
|
||||||
|
<constructor>
|
||||||
|
<postconditions><para><this->empty()></para></postconditions>
|
||||||
|
</constructor>
|
||||||
|
|
||||||
|
<constructor>
|
||||||
|
<parameter name="other">
|
||||||
|
<paramtype>const <classname>any</classname>&amp;</paramtype>
|
||||||
|
</parameter>
|
||||||
|
|
||||||
|
<effects>
|
||||||
|
<simpara> Copy constructor that copies
|
||||||
|
content of <code>other</code> into the new instance,
|
||||||
|
so that any content is equivalent in both type and value to the
|
||||||
|
content of <code>other</code>, or empty if
|
||||||
|
<code>other</code> is
|
||||||
|
empty.
|
||||||
|
</simpara>
|
||||||
|
</effects>
|
||||||
|
|
||||||
|
<throws>
|
||||||
|
<simpara>May fail with a
|
||||||
|
<classname>std::bad_alloc</classname> exception or any
|
||||||
|
exceptions arising from the copy constructor of the
|
||||||
|
contained type.
|
||||||
|
</simpara>
|
||||||
|
</throws>
|
||||||
|
</constructor>
|
||||||
|
|
||||||
|
<destructor>
|
||||||
|
<effects><simpara>Releases any and all resources used in
|
||||||
|
management of instance.</simpara></effects>
|
||||||
|
|
||||||
|
<throws><simpara>Nothing.</simpara></throws>
|
||||||
|
</destructor>
|
||||||
|
</class>
|
||||||
|
</programlisting>
|
||||||
|
|
||||||
|
<table id="boostbook.function.types">
|
||||||
|
<title>BoostBook Function Types</title>
|
||||||
|
|
||||||
|
<tgroup cols="2">
|
||||||
|
<thead>
|
||||||
|
<row>
|
||||||
|
<entry><simpara>C++ Function</simpara></entry>
|
||||||
|
<entry><simpara>BoostBook Element</simpara></entry>
|
||||||
|
</row>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<row>
|
||||||
|
<entry><simpara>Constructor</simpara></entry>
|
||||||
|
<entry><simpara><constructor></simpara></entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><simpara>Destructor</simpara></entry>
|
||||||
|
<entry><simpara><destructor></simpara></entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><simpara>Copy assignment operator</simpara></entry>
|
||||||
|
<entry><simpara><copy-assignment></simpara></entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><simpara>Member function</simpara></entry>
|
||||||
|
<entry><simpara><method></simpara></entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><simpara>Free function</simpara></entry>
|
||||||
|
<entry><simpara><function></simpara></entry>
|
||||||
|
</row>
|
||||||
|
</tbody>
|
||||||
|
</tgroup>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<table id="boostbook.function.clauses">
|
||||||
|
<title>BoostBook Function Semantics Clauses</title>
|
||||||
|
|
||||||
|
<tgroup cols="2">
|
||||||
|
<thead>
|
||||||
|
<row>
|
||||||
|
<entry><simpara>BoostBook element</simpara></entry>
|
||||||
|
<entry><simpara>Description</simpara></entry>
|
||||||
|
</row>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<row>
|
||||||
|
<entry><simpara><requires></simpara></entry>
|
||||||
|
<entry><simpara>A set of requirements that must be met
|
||||||
|
prior to execution of the function (a.k.a.,
|
||||||
|
preconditions). If any of these requirements is not met
|
||||||
|
and the function is executed, then the behavior is
|
||||||
|
undefined.</simpara></entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><simpara><effects></simpara></entry>
|
||||||
|
<entry><simpara>The effects of executing the function. For
|
||||||
|
instance, this may include documenting changes in state,
|
||||||
|
other functions executed, or output written to
|
||||||
|
files.</simpara></entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><simpara><postconditions></simpara></entry>
|
||||||
|
<entry><simpara>Conditions that are guaranteed to hold
|
||||||
|
after execution of the function, assuming that all
|
||||||
|
requirements have been met.</simpara></entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><simpara><returns></simpara></entry>
|
||||||
|
<entry><simpara>A description of the value returned from
|
||||||
|
the function.</simpara></entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><simpara><throws></simpara></entry>
|
||||||
|
<entry><simpara>A description of the exceptions that may
|
||||||
|
be thrown from this function.</simpara></entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><simpara><complexity></simpara></entry>
|
||||||
|
<entry><simpara>The computational complexity of this
|
||||||
|
function.</simpara></entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><simpara><notes></simpara></entry>
|
||||||
|
<entry><simpara>Additional notes that clarify the behavior
|
||||||
|
of the function.</simpara></entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><simpara><rationale></simpara></entry>
|
||||||
|
<entry><simpara>Reasons for the current semantics,
|
||||||
|
including an explanation of potential alternative
|
||||||
|
semantics and reasons why the alternatives have not bee
|
||||||
|
used.</simpara></entry>
|
||||||
|
</row>
|
||||||
|
</tbody>
|
||||||
|
</tgroup>
|
||||||
|
</table>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section id="boostbook.templates">
|
||||||
|
<title>Templates</title>
|
||||||
|
<para>To be written...</para>
|
||||||
|
</section>
|
||||||
|
</section>
|
61
doc/together.xml
Normal file
61
doc/together.xml
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!DOCTYPE section SYSTEM "../../dtd/boostbook.dtd">
|
||||||
|
<section xmlns:xi="http://www.w3.org/2001/XInclude" id="boostbook.together">
|
||||||
|
<title>Bringing Together a BoostBook Document</title>
|
||||||
|
|
||||||
|
<section id="boostbook.linking">
|
||||||
|
<title>Linking in BoostBook</title>
|
||||||
|
|
||||||
|
<para>How one links to another element in BoostBook depends
|
||||||
|
greatly on the nature of the element linked and how the link
|
||||||
|
should appear. There are three general linking elements:
|
||||||
|
<xref>, <link>, and >ulink>. Additionally, there
|
||||||
|
are linking elements for referencing specific types of entities,
|
||||||
|
such as classes (<classname>), functions
|
||||||
|
(<functionname>), or libraries (<libraryname>).</para>
|
||||||
|
|
||||||
|
<para>The <xref> element references elements that have an
|
||||||
|
<code>id</code> attribute and a title. The actual link text is
|
||||||
|
composed from title and type of the element referenced. To link to
|
||||||
|
a particular ID, create an <xref> element with the
|
||||||
|
<code>linkend</code> attribute set to the ID of the intended
|
||||||
|
target. For instance, this section's ID is
|
||||||
|
<code>boostbook.linking</code>, so we create a reference it to
|
||||||
|
with <code><xref linkend="boostbook.linking"/></code>, which
|
||||||
|
will look like this in the text: <xref
|
||||||
|
linkend="boostbook.linking"/>.</para>
|
||||||
|
|
||||||
|
<para>The <link> element references an ID in the same way as
|
||||||
|
<xref>, except that <link> does not generate any text
|
||||||
|
for the link, so text must be supplied within the element. For
|
||||||
|
instance, we can again link to this chapter but this time specify
|
||||||
|
our own text with <code><link
|
||||||
|
linkend="boostbook.linking">like this</link></code>. This
|
||||||
|
markup will result in a link to this chapter that looks <link
|
||||||
|
linkend="boostbook.linking">like this</link>.</para>
|
||||||
|
|
||||||
|
<para>The <ulink> element references a URL that is outside
|
||||||
|
of the DocBook document. The <code>url</code> attribute contains
|
||||||
|
the URL to link to, and the element data provides the link
|
||||||
|
text.For instance, we can link to the the Boost web site with
|
||||||
|
<code><ulink
|
||||||
|
url="http://www.boost.org">Boost</ulink>,</code> which
|
||||||
|
appears in the document like this: <ulink
|
||||||
|
url="http://www.boost.org">Boost</ulink>.</para>
|
||||||
|
|
||||||
|
<para>The <classname>, <functionname>,
|
||||||
|
<methodname>, and <libraryname> link to classes,
|
||||||
|
functions, methods, and libraries, respectively. The text of each
|
||||||
|
element gives both the name of the element to link to and the link
|
||||||
|
text. For instance, we can link to the Function library with
|
||||||
|
<code><libraryname>Function</libraryname></code>,
|
||||||
|
which results in the following:
|
||||||
|
<libraryname>Function</libraryname>. In cases where the displayed
|
||||||
|
text is different from the actual name, the <code>alt</code>
|
||||||
|
attribute can be specified. For instance, the following XML
|
||||||
|
element references the <classname>boost::function</classname>
|
||||||
|
class template but displays the text <classname
|
||||||
|
alt="boost::function">function</classname>: <code><classname
|
||||||
|
alt="boost::function">function</classname></code>.</para>
|
||||||
|
</section>
|
||||||
|
</section>
|
Loading…
x
Reference in New Issue
Block a user