[29] | 1 | <?xml version="1.0" encoding="utf-8"?> |
---|
| 2 | <!-- |
---|
| 3 | Copyright (c) 2002 Douglas Gregor <doug.gregor -at- gmail.com> |
---|
| 4 | |
---|
| 5 | Distributed under the Boost Software License, Version 1.0. |
---|
| 6 | (See accompanying file LICENSE_1_0.txt or copy at |
---|
| 7 | http://www.boost.org/LICENSE_1_0.txt) |
---|
| 8 | --> |
---|
| 9 | <!DOCTYPE part PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN" |
---|
| 10 | "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd"> |
---|
| 11 | <part xmlns:xi="http://www.w3.org/2001/XInclude" id="boostbook" |
---|
| 12 | last-revision="$Date: 2006/12/15 13:06:32 $"> |
---|
| 13 | <partinfo> |
---|
| 14 | <author> |
---|
| 15 | <firstname>Douglas</firstname> |
---|
| 16 | <surname>Gregor</surname> |
---|
| 17 | </author> |
---|
| 18 | |
---|
| 19 | <copyright> |
---|
| 20 | <year>2003</year> |
---|
| 21 | <year>2004</year> |
---|
| 22 | <year>2005</year> |
---|
| 23 | <holder>Douglas Gregor</holder> |
---|
| 24 | </copyright> |
---|
| 25 | |
---|
| 26 | <legalnotice> |
---|
| 27 | <para>Permission to copy, use, sell and distribute this software |
---|
| 28 | is granted provided this copyright notice appears in all copies. |
---|
| 29 | Permission to modify the code and to distribute modified code is |
---|
| 30 | granted provided this copyright notice appears in all copies, |
---|
| 31 | and a notice that the code was modified is included with the |
---|
| 32 | copyright notice. </para> |
---|
| 33 | |
---|
| 34 | <para> This software is provided "as is" without express or |
---|
| 35 | implied warranty, and with no claim as to its suitability for |
---|
| 36 | any purpose. </para> |
---|
| 37 | </legalnotice> |
---|
| 38 | </partinfo> |
---|
| 39 | |
---|
| 40 | <title>The BoostBook Documentation Format</title> |
---|
| 41 | |
---|
| 42 | <chapter id="boostbook.introduction"> |
---|
| 43 | <title>Introduction</title> |
---|
| 44 | |
---|
| 45 | <para>The BoostBook documentation format is an extension of <ulink |
---|
| 46 | url="http://www.docbook.org">DocBook</ulink>, an SGML- or |
---|
| 47 | XML-based format for describing documentation. BoostBook augments |
---|
| 48 | DocBook with semantic markup that aids in the documentation of C++ |
---|
| 49 | libraries, specifically the <ulink |
---|
| 50 | url="http://www.boost.org">Boost C++ libraries</ulink>, by |
---|
| 51 | providing the ability to express and refer to C++ constructs such |
---|
| 52 | as namespaces, classes, overloaded functions, templates, and |
---|
| 53 | specializations.</para> |
---|
| 54 | |
---|
| 55 | <para> |
---|
| 56 | BoostBook offers additional features more specific to its use for |
---|
| 57 | documenting the <ulink url="http://www.boost.org">Boost C++ |
---|
| 58 | libraries</ulink>. These features are intended to eliminate or |
---|
| 59 | reduce the need for duplication of information and to aid in |
---|
| 60 | documenting portions of Boost that might otherwise not be |
---|
| 61 | documented. Examples of Boost-centric features include: |
---|
| 62 | <itemizedlist> |
---|
| 63 | <listitem> |
---|
| 64 | <para><emphasis role="bold">Testsuites</emphasis>: |
---|
| 65 | Testsuites in Boost are created by writing an appropriate |
---|
| 66 | Jamfile and including that Jamfile in |
---|
| 67 | <filename>status/Jamfile</filename>. If the testsuites are |
---|
| 68 | documented (<ulink |
---|
| 69 | url="http://www.boost.org/libs/multi_array/doc/test_cases.html">as |
---|
| 70 | in the MultiArray library</ulink>), the documentation is |
---|
| 71 | maintained separately from the testcase Jamfile, leading to |
---|
| 72 | duplication of information and the possibility of having the |
---|
| 73 | documentation out of sync with the Jamfile. BoostBook |
---|
| 74 | contains elements that describe a testsuite for both |
---|
| 75 | purposes: the BoostBook stylesheets can generate |
---|
| 76 | documentation for the testcases and also generate an |
---|
| 77 | appropriate Jamfile to integrate the testcases with the |
---|
| 78 | regression testing system.</para> |
---|
| 79 | </listitem> |
---|
| 80 | <listitem> |
---|
| 81 | <para><emphasis role="bold">Example programs</emphasis>: |
---|
| 82 | Example programs in documentation need to be duplicated in |
---|
| 83 | testcases to ensure that the examples compile and execute |
---|
| 84 | correctly. Keeping the two copies in sync is a tedious and |
---|
| 85 | error-prone task. For instance, the following code snippet |
---|
| 86 | persisted for six months:</para> |
---|
| 87 | <programlisting> |
---|
| 88 | std::cout << f(5, 3) >> std::endl; |
---|
| 89 | </programlisting> |
---|
| 90 | <para>The BoostBook format allows testcases to be generated |
---|
| 91 | by weaving together program fragments from example programs |
---|
| 92 | in the documentation. This capability is integrated with |
---|
| 93 | testsuite generation so that example programs are normal |
---|
| 94 | tests in BoostBook.</para> |
---|
| 95 | </listitem> |
---|
| 96 | </itemizedlist> |
---|
| 97 | </para> |
---|
| 98 | </chapter> |
---|
| 99 | |
---|
| 100 | <chapter id="boostbook.getting.started"> |
---|
| 101 | <title>Getting Started</title> |
---|
| 102 | |
---|
| 103 | <para>To use the Boost documentation tools, you will need several tools:</para> |
---|
| 104 | <itemizedlist> |
---|
| 105 | <listitem><simpara><command>xsltproc</command>:</simpara> |
---|
| 106 | <itemizedlist> |
---|
| 107 | <listitem>Windows with <ulink |
---|
| 108 | url="http://www.cygwin.com/">Cygwin</ulink>: select the libxml2 and libxslt packages.</listitem> |
---|
| 109 | <listitem>Windows without Cygwin: Download packages <ulink url="http://www.meta-comm.com/engineering/boost/xsltproc-win32.zip"> |
---|
| 110 | here</ulink>.</listitem> |
---|
| 111 | <listitem>Mac OS X with Fink: Get the <code>libxslt</code> package.</listitem> |
---|
| 112 | <listitem>Mac OS X without Fink: <ulink url="http://www.zveno.com/open_source/libxml2xslt.html">Download the libxslt binaries</ulink></listitem> |
---|
| 113 | <listitem>Any platform: <ulink |
---|
| 114 | url="http://xmlsoft.org/XSLT/">libxslt source</ulink>.</listitem> |
---|
| 115 | </itemizedlist> |
---|
| 116 | </listitem> |
---|
| 117 | <listitem><simpara><command>doxygen</command>:</simpara> Available from <ulink url="http://www.doxygen.org">http://www.doxygen.org</ulink></listitem> |
---|
| 118 | </itemizedlist> |
---|
| 119 | |
---|
| 120 | <section id="boostbook.setup.autounix"> |
---|
| 121 | <title>Automatic setup for Unix-like systems</title> |
---|
| 122 | |
---|
| 123 | <para>BoostBook provides a nearly-automatic setup script. Once |
---|
| 124 | you have downloaded and |
---|
| 125 | installed <command>xsltproc</command>, <command>doxygen</command>, |
---|
| 126 | and (optionally) <command>java</command>, the setup script can |
---|
| 127 | download the required DocBook stylesheets, DocBook DTD, and |
---|
| 128 | (when Java is enabled) Apache FOP for PDF output. It will then |
---|
| 129 | configure Boost.Build version 2 to build BoostBook |
---|
| 130 | documentation. To perform the installation, execute the |
---|
| 131 | script <command>tools/boostbook/setup_boostbook.sh</command> |
---|
| 132 | from a directory where you would like the resulting XSL, DTD, |
---|
| 133 | and Apache FOP installations to occur. </para> |
---|
| 134 | </section> |
---|
| 135 | |
---|
| 136 | <section id="boostbook.setup.manual"> |
---|
| 137 | <title>Manual setup for all systems</title> |
---|
| 138 | |
---|
| 139 | <para>This section describes how to manually configure Boost |
---|
| 140 | Boost version 2 (BBv2) for BoostBook. If you can use the |
---|
| 141 | automatic setup script, you should. All configuration will |
---|
| 142 | happen in the BBv2 user configuration file, |
---|
| 143 | <filename>user-config.jam</filename>. If you do not have a copy |
---|
| 144 | of this file in your home directory, you should copy the one |
---|
| 145 | that resides in <code>tools/build/v2</code> to your home |
---|
| 146 | directory. Alternatively, you can edit |
---|
| 147 | <filename>tools/build/v2/user-config.jam</filename> directly or |
---|
| 148 | a site-wide <filename>site-config.jam</filename> file.</para> |
---|
| 149 | |
---|
| 150 | <section id="boostbook.setup.xsltproc"> |
---|
| 151 | <title>Configuring <command>xsltproc</command></title> |
---|
| 152 | |
---|
| 153 | <para>To configure <command>xsltproc</command> manually, you |
---|
| 154 | will need to add a directive to |
---|
| 155 | <filename>user-config.jam</filename> telling it where to find |
---|
| 156 | <command>xsltproc</command>. If the program is in your path, |
---|
| 157 | just add the following line to |
---|
| 158 | <filename>user-config.jam</filename>:</para> |
---|
| 159 | |
---|
| 160 | <programlisting>using xsltproc ;</programlisting> |
---|
| 161 | |
---|
| 162 | <para>If <command>xsltproc</command> is somewhere else, use |
---|
| 163 | this directive, where <code>XSLTPROC</code> is the full |
---|
| 164 | pathname to <command>xsltproc</command> (including |
---|
| 165 | <command>xsltproc</command>):</para> |
---|
| 166 | |
---|
| 167 | <programlisting>using xsltproc : XSLTPROC ;</programlisting> |
---|
| 168 | </section> |
---|
| 169 | |
---|
| 170 | <section id="boostbook.setup.docbook"> |
---|
| 171 | <title>Configuring local DocBook XSL and DTD distributions</title> |
---|
| 172 | |
---|
| 173 | <para>This section describes how to configure Boost.Build to |
---|
| 174 | use local copies of the DocBook DTD and XSL stylesheets to |
---|
| 175 | improve processing time. You will first need to download two |
---|
| 176 | packages: |
---|
| 177 | |
---|
| 178 | <itemizedlist> |
---|
| 179 | <listitem><para>Norman Walsh's DocBook XSL stylesheets, |
---|
| 180 | available at the <ulink |
---|
| 181 | url="http://docbook.sourceforge.net">DocBook sourceforge |
---|
| 182 | site</ulink>. Extract the DocBook XSL stylesheets to a |
---|
| 183 | directory on your hard disk (which we'll refer to as the |
---|
| 184 | <code>DOCBOOK_XSL_DIR</code>).</para> |
---|
| 185 | </listitem> |
---|
| 186 | |
---|
| 187 | <listitem><para>The DocBook DTD, available as a ZIP archive |
---|
| 188 | at the <ulink |
---|
| 189 | url="http://www.oasis-open.org/docbook/xml/4.2/index.1.shtml">OASIS |
---|
| 190 | DocBook site</ulink>. The package is called "DocBook XML |
---|
| 191 | 4.2". Extract the DocBook DTD to a directory on your hard |
---|
| 192 | disk (which we'll refer to as the |
---|
| 193 | <code>DOCBOOK_DTD_DIR</code>). You will want to extract this |
---|
| 194 | archive in a subdirectory!</para></listitem> |
---|
| 195 | </itemizedlist> |
---|
| 196 | </para> |
---|
| 197 | |
---|
| 198 | <para>Add the following directive telling BBv2 where to find |
---|
| 199 | the DocBook DTD and XSL stylesheets:</para> |
---|
| 200 | |
---|
| 201 | <programlisting># BoostBook configuration |
---|
| 202 | using boostbook |
---|
| 203 | : DOCBOOK_XSL_DIR |
---|
| 204 | : DOCBOOK_DTD_DIR |
---|
| 205 | ;</programlisting> |
---|
| 206 | |
---|
| 207 | <para>Whenever you change this directive, you will need to |
---|
| 208 | remove the <code>bin.v2</code> directory that BBv2 generates. |
---|
| 209 | This is due to longstanding bug we are trying to fix.</para> |
---|
| 210 | |
---|
| 211 | <para>At this point, you should be able to build HTML |
---|
| 212 | documentation for libraries that do not require Doxygen. To |
---|
| 213 | test this, change into the directory <filename |
---|
| 214 | class="directory">$BOOST_ROOT/libs/function/doc</filename> and |
---|
| 215 | run the command <code>bjam</code>: it should produce HTML |
---|
| 216 | documentation for the Boost.Function library in the |
---|
| 217 | <code>html</code> subdirectory. This documentation |
---|
| 218 | will look a little strange, because the BoostBook stylesheet is |
---|
| 219 | missing. You can copy the <code>boostbook.css</code> stylesheet from |
---|
| 220 | <filename class="directory">$BOOST_ROOT/doc/html</filename> to |
---|
| 221 | fix this problem.</para> |
---|
| 222 | </section> |
---|
| 223 | |
---|
| 224 | <section id="boostbook.setup.doxygen"> |
---|
| 225 | <title>Configuring Doxygen for Documentation Extraction</title> |
---|
| 226 | |
---|
| 227 | <para>Doxygen is required to build the documentation for |
---|
| 228 | several Boost libraries. You will need a recent version of |
---|
| 229 | <ulink url="http://www.doxygen.org">Doxygen</ulink> (most of |
---|
| 230 | the 1.3.x and 1.4.x versions will suffice). BBv2 by adding the |
---|
| 231 | following directive to |
---|
| 232 | <filename>user-config.jam</filename>:</para> |
---|
| 233 | |
---|
| 234 | <programlisting>using doxygen : DOXYGEN ;</programlisting> |
---|
| 235 | |
---|
| 236 | <para><filename>DOXYGEN</filename> should be replaced with the |
---|
| 237 | name of the <command>doxygen</command> executable (with full |
---|
| 238 | path name). If the right <command>doxygen</command> executable |
---|
| 239 | can be found via the path, this parameter can be |
---|
| 240 | omitted, e.g.</para> |
---|
| 241 | |
---|
| 242 | <programlisting>using doxygen ;</programlisting> |
---|
| 243 | |
---|
| 244 | <important> |
---|
| 245 | <para>The relative order of declarations in |
---|
| 246 | <filename>user-config.jam</filename> / |
---|
| 247 | <filename>site-config.jam</filename> files is |
---|
| 248 | significant. In particular, the <literal>using |
---|
| 249 | doxygen</literal> line should come |
---|
| 250 | <emphasis>after</emphasis> the <literal>using |
---|
| 251 | boostbook</literal> declaration. |
---|
| 252 | </para> |
---|
| 253 | </important> |
---|
| 254 | </section> |
---|
| 255 | |
---|
| 256 | <section id="boostbook.setup.fop"> |
---|
| 257 | <title>Configuring Apache FOP</title> |
---|
| 258 | |
---|
| 259 | <para>In order to generate PDF and PostScript output using |
---|
| 260 | Apache FOP, you will need a <ulink |
---|
| 261 | url="http://java.sun.com">Java interpreter</ulink> and <ulink |
---|
| 262 | url="http://xml.apache.org/fop/download.html">Apache FOP</ulink> |
---|
| 263 | (version 0.20.5 is best). Unpack Apache FOP to some |
---|
| 264 | directory. The top level directory of the FOP tool should |
---|
| 265 | contain a main script called <filename>fop.sh</filename> on Unix |
---|
| 266 | and <filename>fop.bat</filename> on Windows. You need to specify |
---|
| 267 | the location of that script and Java location to |
---|
| 268 | Boost.Build. Add the following to your |
---|
| 269 | <filename>user-config.jam</filename> or |
---|
| 270 | <filename>site-config.jam</filename>: |
---|
| 271 | <programlisting> |
---|
| 272 | using fop : FOP_COMMAND |
---|
| 273 | : JAVA_HOME |
---|
| 274 | ; |
---|
| 275 | </programlisting> replacing |
---|
| 276 | <code>FOP_COMMAND</code> with the full path to the FOP main script, and |
---|
| 277 | replacing <code>JAVA_HOME</code> with the directory where Java is |
---|
| 278 | installed. If the <envar>JAVA_HOME</envar> environment variable is |
---|
| 279 | already set, you don't need to specify it above. |
---|
| 280 | </para> |
---|
| 281 | |
---|
| 282 | <para> |
---|
| 283 | Proper generation of images in PDFs depends on the <ulink |
---|
| 284 | url="http://java.sun.com/products/jimi/#">Jimi Image |
---|
| 285 | Library</ulink>. To get FOP to use Jimi, extract the |
---|
| 286 | <filename>JimiProClasses.zip</filename> file from the Jimi SDK |
---|
| 287 | and rename it—if on Windows, to |
---|
| 288 | <filename>jimi-1.0.jar</filename>, or if on *nix, to |
---|
| 289 | <filename>JimiProClasses.jar</filename>—and place it in the |
---|
| 290 | <filename>lib/</filename> subdirectory of your FOP |
---|
| 291 | installation. |
---|
| 292 | </para> |
---|
| 293 | |
---|
| 294 | <para>To test PDF generation, switch to the directory <filename |
---|
| 295 | class="directory">$BOOST_ROOT/libs/function/doc</filename> and |
---|
| 296 | execute the command <command>bjam --v2 pdf</command>. In the |
---|
| 297 | absence of any errors, Apache FOP will be executed to transform |
---|
| 298 | the XSL:FO output of DocBook into a PDF file.</para> |
---|
| 299 | </section> |
---|
| 300 | </section> |
---|
| 301 | |
---|
| 302 | <section id="boostbook.setup.running"> |
---|
| 303 | <title>Running BoostBook</title> |
---|
| 304 | |
---|
| 305 | <para>Once BoostBook has been configured, we can build some |
---|
| 306 | documentation. First, change to the directory |
---|
| 307 | <code>$BOOST_ROOT/doc</code> and remove (or make writable) the |
---|
| 308 | <code>.html</code> files in |
---|
| 309 | <code>$BOOST_ROOT/doc/html</code>. Then, run <code>bjam |
---|
| 310 | --v2</code> to build HTML documentation. You should see several |
---|
| 311 | warnings like these while DocBook documentation is being built |
---|
| 312 | from BoostBook documentation:</para> |
---|
| 313 | |
---|
| 314 | <programlisting>Cannot find function named 'checked_delete' |
---|
| 315 | Cannot find function named 'checked_array_delete' |
---|
| 316 | Cannot find function named 'next'</programlisting> |
---|
| 317 | |
---|
| 318 | <para>These warnings are emitted when the Boost documentation |
---|
| 319 | tools cannot find documentation for functions, methods, or classes |
---|
| 320 | that are referenced in the source, and are not harmful in any |
---|
| 321 | way. Once Boost.Jam has completed its execution, HTML |
---|
| 322 | documentation for Boost will be available in |
---|
| 323 | <code>$BOOST_ROOT/doc/html</code>. You can also create HTML |
---|
| 324 | documentation in a single (large!) HTML file with the command line |
---|
| 325 | <code>bjam --v2 onehtml</code>, or Unix man pages with the command |
---|
| 326 | line <code>bjam --v2 man</code>. The complete list of output |
---|
| 327 | formats is listed in <xref |
---|
| 328 | linkend="boostbook.output.formats"/>. Several output formats can |
---|
| 329 | be passed to a single invocation of <code>bjam</code>, e.g., |
---|
| 330 | <code>bjam --v2 html man docbook</code> would generate HTML |
---|
| 331 | (multiple files), man pages, and DocBook documentation.</para> |
---|
| 332 | |
---|
| 333 | <table id="boostbook.output.formats"> |
---|
| 334 | <title>BoostBook Output Formats</title> |
---|
| 335 | <tgroup cols="2"> |
---|
| 336 | <thead> |
---|
| 337 | <row><entry>Format</entry><entry>Description</entry></row> |
---|
| 338 | </thead> |
---|
| 339 | <tbody> |
---|
| 340 | <row> |
---|
| 341 | <entry>html</entry> |
---|
| 342 | <entry><simpara>HTML output (multiple files). This is the default</simpara></entry> |
---|
| 343 | </row> |
---|
| 344 | <row> |
---|
| 345 | <entry>onehtml</entry> |
---|
| 346 | <entry><simpara>HTML output in a single HTML file.</simpara></entry> |
---|
| 347 | </row> |
---|
| 348 | <row> |
---|
| 349 | <entry>man</entry> |
---|
| 350 | <entry><simpara>Unix man pages.</simpara></entry> |
---|
| 351 | </row> |
---|
| 352 | <row> |
---|
| 353 | <entry>pdf</entry> |
---|
| 354 | <entry><simpara>PDF. Requires <ulink url="http://xml.apache.org/fop/index.html">Apache FOP</ulink>.</simpara></entry> |
---|
| 355 | </row> |
---|
| 356 | <row> |
---|
| 357 | <entry>ps</entry> |
---|
| 358 | <entry><simpara>Postscript. Requires <ulink url="http://xml.apache.org/fop/index.html">Apache FOP</ulink>.</simpara></entry> |
---|
| 359 | </row> |
---|
| 360 | <row> |
---|
| 361 | <entry>docbook</entry> |
---|
| 362 | <entry><ulink url="http://www.docbook.org/">DocBook</ulink>.</entry> |
---|
| 363 | </row> |
---|
| 364 | <row> |
---|
| 365 | <entry>fo</entry> |
---|
| 366 | <entry><ulink url="http://www.w3.org/TR/xsl/">XSL Formatting Objects</ulink></entry> |
---|
| 367 | </row> |
---|
| 368 | </tbody> |
---|
| 369 | </tgroup> |
---|
| 370 | </table> |
---|
| 371 | </section> |
---|
| 372 | |
---|
| 373 | <section id="boostbook.setup.troubleshooting"> |
---|
| 374 | <title>Troubleshooting</title> |
---|
| 375 | |
---|
| 376 | <para>The Boost documentation tools are still in their early phase of |
---|
| 377 | development, and some things don't work as seamlessly as we would like |
---|
| 378 | them to, yet. In particular, error messages can be somewhat |
---|
| 379 | uninformative at times. If you find yourself in the situation when |
---|
| 380 | you have double checked everything, and yet things still don't work as |
---|
| 381 | expected, consider helping the tools by deleting |
---|
| 382 | <literal>bin.v2</literal> build directory. |
---|
| 383 | </para> |
---|
| 384 | |
---|
| 385 | </section> |
---|
| 386 | </chapter> |
---|
| 387 | |
---|
| 388 | <xi:include href="documenting.xml"/> |
---|
| 389 | <xi:include href="together.xml"/> |
---|
| 390 | <xi:include href="reference.xml"/> |
---|
| 391 | </part> |
---|