xref: /netbsd-src/external/gpl3/gcc.old/dist/libstdc++-v3/doc/html/manual/documentation_hacking.html (revision 95b39c65ca575fb40c6bb7083e0eb7ec28eabef1)
1<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Writing and Generating Documentation</title><meta name="generator" content="DocBook XSL-NS Stylesheets V1.78.1" /><meta name="keywords" content="ISO C++, documentation, style, docbook, doxygen" /><meta name="keywords" content="ISO C++, library" /><meta name="keywords" content="ISO C++, runtime, library" /><link rel="home" href="../index.html" title="The GNU C++ Library" /><link rel="up" href="appendix_porting.html" title="Appendix B.  Porting and Maintenance" /><link rel="prev" href="appendix_porting.html" title="Appendix B.  Porting and Maintenance" /><link rel="next" href="internals.html" title="Porting to New Hardware or Operating Systems" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Writing and Generating Documentation</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="appendix_porting.html">Prev</a> </td><th width="60%" align="center">Appendix B. 
3  Porting and Maintenance
4
5</th><td width="20%" align="right"> <a accesskey="n" href="internals.html">Next</a></td></tr></table><hr /></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="appendix.porting.doc"></a>Writing and Generating Documentation</h2></div></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="doc.intro"></a>Introduction</h3></div></div></div><p>
6      Documentation for the GNU C++ Library is created from three
7      independent sources: a manual, a FAQ, and an API reference.
8    </p><p>
9      The sub-directory <code class="filename">doc</code>
10      within the main source directory contains
11      <code class="filename">Makefile.am</code> and
12      <code class="filename">Makefile.in</code>, which provide rules for
13      generating documentation, described in excruciating detail
14      below. The <code class="filename">doc</code>
15      sub-directory also contains three directories: <code class="filename">doxygen</code>, which contains scripts and
16      fragments for <span class="command"><strong>doxygen</strong></span>, <code class="filename">html</code>, which contains an html
17      version of the manual, and <code class="filename">xml</code>, which contains an xml version
18      of the manual.
19    </p><p>
20      Diverging from established documentation conventions in the rest
21      of the GCC project, libstdc++ does not use Texinfo as a markup
22      language. Instead, Docbook is used to create the manual and the
23      FAQ, and Doxygen is used to construct the API
24      reference. Although divergent, this conforms to the GNU Project
25      recommendations as long as the output is of sufficient quality,
26      as per
27      <a class="link" href="http://www.gnu.org/prep/standards/standards.html#Documentation" target="_top">
28      GNU Manuals</a>.
29    </p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="doc.generation"></a>Generating Documentation</h3></div></div></div><p>
30      Certain Makefile rules are required by the GNU Coding
31      Standards. These standard rules generate HTML, PDF, XML, or man
32      files. For each of the generative rules, there is an additional
33      install rule that is used to install any generated documentation
34      files into the prescribed installation directory. Files are
35      installed into <code class="filename">share/doc</code>
36      or <code class="filename">share/man</code> directories.
37    </p><p>
38      The standard Makefile rules are conditionally supported, based
39      on the results of examining the host environment for
40      prerequisites at configuration time. If requirements are not
41      found, the rule is aliased to a dummy rule that does nothing,
42      and produces no documentation. If the requirements are found,
43      the rule forwards to a private rule that produces the requested
44      documentation.
45    </p><p>
46      For more details on what prerequisites were found and where,
47      please consult the file <code class="filename">config.log</code> in the
48      libstdc++ build directory. Compare this log to what is expected
49      for the relevant Makefile conditionals:
50      <code class="literal">BUILD_INFO</code>, <code class="literal">BUILD_XML</code>,
51      <code class="literal">BUILD_HTML</code>, <code class="literal">BUILD_MAN</code>,
52      <code class="literal">BUILD_PDF</code>, and <code class="literal">BUILD_EPUB</code>.
53    </p><p>
54      Supported Makefile rules:
55    </p><div class="variablelist"><dl class="variablelist"><dt><span class="term">
56	  <span class="emphasis"><em>make html</em></span>
57	, </span><span class="term">
58	  <span class="emphasis"><em>make install-html</em></span>
59	</span></dt><dd><p>
60	    Generates multi-page HTML documentation, and installs it
61	    in the following directories:
62	  </p><p>
63	    <code class="filename">doc/libstdc++/libstdc++-api.html</code>
64	  </p><p>
65	    <code class="filename">doc/libstdc++/libstdc++-manual.html</code>
66	  </p></dd><dt><span class="term">
67	  <span class="emphasis"><em>make pdf</em></span>
68	, </span><span class="term">
69	  <span class="emphasis"><em>make install-pdf</em></span>
70	</span></dt><dd><p>
71	    Generates indexed PDF documentation, and installs it as
72	    the following files:
73	  </p><p>
74	    <code class="filename">doc/libstdc++/libstdc++-api.pdf</code>
75	  </p><p>
76	    <code class="filename">doc/libstdc++/libstdc++-manual.pdf</code>
77	  </p></dd><dt><span class="term">
78	  <span class="emphasis"><em>make man</em></span>
79	, </span><span class="term">
80	  <span class="emphasis"><em>make install-man</em></span>
81	</span></dt><dd><p>
82	    Generates man pages, and installs it in the following directory:
83	  </p><p>
84	    <code class="filename">man/man3/</code>
85	  </p><p>
86	    The generated man pages are namespace-qualified, so to look at
87	    the man page for <code class="classname">vector</code>, one would use
88	    <span class="command"><strong>man std::vector</strong></span>.
89	  </p></dd><dt><span class="term">
90	  <span class="emphasis"><em>make epub</em></span>
91	, </span><span class="term">
92	  <span class="emphasis"><em>make install-epub</em></span>
93	</span></dt><dd><p>
94	    Generates documentation in the ebook/portable electronic
95	    reader format called Epub, and installs it as the
96	    following file.
97	  </p><p>
98	    <code class="filename">doc/libstdc++/libstdc++-manual.epub</code>
99	  </p></dd><dt><span class="term">
100	  <span class="emphasis"><em>make xml</em></span>
101	, </span><span class="term">
102	  <span class="emphasis"><em>make install-xml</em></span>
103	</span></dt><dd><p>
104	    Generates single-file XML documentation, and installs it
105	    as the following files:
106	  </p><p>
107	    <code class="filename">doc/libstdc++/libstdc++-api-single.xml</code>
108	  </p><p>
109	    <code class="filename">doc/libstdc++/libstdc++-manual-single.xml</code>
110	  </p></dd></dl></div><p>
111      Makefile rules for several other formats are explicitly not
112      supported, and are always aliased to dummy rules. These
113      unsupported formats are: <span class="emphasis"><em>info</em></span>,
114      <span class="emphasis"><em>ps</em></span>, and <span class="emphasis"><em>dvi</em></span>.
115    </p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="doc.doxygen"></a>Doxygen</h3></div></div></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a id="doxygen.prereq"></a>Prerequisites</h4></div></div></div><div class="table"><a id="idm269993370272"></a><p class="title"><strong>Table B.1. Doxygen Prerequisites</strong></p><div class="table-contents"><table summary="Doxygen Prerequisites" border="1"><colgroup><col align="center" class="c1" /><col align="center" class="c2" /><col align="center" class="c3" /></colgroup><thead><tr><th align="center">Tool</th><th align="center">Version</th><th align="center">Required By</th></tr></thead><tbody><tr><td align="center">coreutils</td><td align="center">8.5</td><td align="center">all</td></tr><tr><td align="center">bash</td><td align="center">4.1</td><td align="center">all</td></tr><tr><td align="center">doxygen</td><td align="center">1.7.6.1</td><td align="center">all</td></tr><tr><td align="center">graphviz</td><td align="center">2.26</td><td align="center">graphical hierarchies</td></tr><tr><td align="center">pdflatex</td><td align="center">2007-59</td><td align="center">pdf output</td></tr></tbody></table></div></div><br class="table-break" /><p>
116	Prerequisite tools are Bash 2.0 or later,
117	<a class="link" href="http://www.doxygen.org/" target="_top">Doxygen</a>, and
118	the <a class="link" href="http://www.gnu.org/software/coreutils/" target="_top">GNU
119	coreutils</a>. (GNU versions of find, xargs, and possibly
120	sed and grep are used, just because the GNU versions make
121	things very easy.)
122      </p><p>
123	To generate the pretty pictures and hierarchy
124	graphs, the
125	<a class="link" href="http://www.graphviz.org" target="_top">Graphviz</a> package
126	will need to be installed. For PDF
127	output, <a class="link" href="http://www.tug.org/applications/pdftex/" target="_top">
128	pdflatex</a> is required.
129      </p><p>
130	Be warned the PDF file generated via doxygen is extremely
131	large. At last count, the PDF file is over three thousand
132	pages. Generating this document taxes the underlying TeX
133	formatting system, and will require the expansion of TeX's memory
134	capacity. Specifically, the <code class="literal">pool_size</code>
135	variable in the configuration file <code class="filename">texmf.cnf</code> may
136	need to be increased by a minimum factor of two.
137      </p></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a id="doxygen.rules"></a>Generating the Doxygen Files</h4></div></div></div><p>
138	The following Makefile rules run Doxygen to generate HTML
139	docs, XML docs, XML docs as a single file, PDF docs, and the
140	man pages. These rules are not conditional! If the required
141	tools are not found, or are the wrong versions, the rule may
142	end in an error.
143      </p><p>
144      </p><pre class="screen"><strong class="userinput"><code>make doc-html-doxygen</code></strong></pre><p>
145      </p><p>
146      </p><pre class="screen"><strong class="userinput"><code>make doc-xml-doxygen</code></strong></pre><p>
147      </p><p>
148      </p><pre class="screen"><strong class="userinput"><code>make doc-xml-single-doxygen</code></strong></pre><p>
149      </p><p>
150      </p><pre class="screen"><strong class="userinput"><code>make doc-pdf-doxygen</code></strong></pre><p>
151      </p><p>
152      </p><pre class="screen"><strong class="userinput"><code>make doc-man-doxygen</code></strong></pre><p>
153      </p><p>
154	Generated files are output into separate sub directories of
155	<code class="filename">doc/doxygen/</code> in the
156	build directory, based on the output format. For instance, the
157	HTML docs will be in <code class="filename">doc/doxygen/html</code>.
158      </p><p>
159	Careful observers will see that the Makefile rules simply call
160	a script from the source tree, <code class="filename">run_doxygen</code>, which
161	does the actual work of running Doxygen and then (most
162	importantly) massaging the output files. If for some reason
163	you prefer to not go through the Makefile, you can call this
164	script directly. (Start by passing <code class="literal">--help</code>.)
165      </p><p>
166	If you wish to tweak the Doxygen settings, do so by editing
167	<code class="filename">doc/doxygen/user.cfg.in</code>. Notes to fellow
168	library hackers are written in triple-# comments.
169      </p></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a id="doxygen.debug"></a>Debugging Generation</h4></div></div></div><p>
170	  Sometimes, mis-configuration of the pre-requisite tools can
171	  lead to errors when attempting to build the
172	  documentation. Here are some of the obvious errors, and ways
173	  to fix some common issues that may appear quite cryptic.
174	</p><p>
175	  First, if using a rule like <code class="code">make pdf</code>, try to
176	  narrow down the scope of the error to either docbook
177	  (<code class="code">make doc-pdf-docbook</code>) or doxygen (<code class="code">make
178	  doc-pdf-doxygen</code>).
179	</p><p>
180	  Working on the doxygen path only, closely examine the
181	  contents of the following build directory:
182	  <code class="filename">build/target/libstdc++-v3/doc/doxygen/latex</code>.
183	  Pay attention to three files enclosed within, annotated as follows.
184	</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>
185   <span class="emphasis"><em>refman.tex</em></span>
186  </p><p>
187    The actual latex file, or partial latex file. This is generated
188    via <span class="command"><strong>doxygen</strong></span>, and is the LaTeX version of the
189    Doxygen XML file <code class="filename">libstdc++-api.xml</code>. Go to a specific
190    line, and look at the genrated LaTeX, and try to deduce what
191    markup in <code class="filename">libstdc++-api.xml</code> is causing it.
192  </p></li><li class="listitem"><p>
193   <span class="emphasis"><em>refman.out</em></span>
194  </p><p>
195    A log of the compilation of the converted LaTeX form to pdf. This
196    is a linear list, from the beginning of the
197    <code class="filename">refman.tex</code> file: the last entry of this file
198    should be the end of the LaTeX file. If it is truncated, then you
199    know that the last entry is the last part of the generated LaTeX
200    source file that is valid. Often this file contains an error with
201    a specific line number of <code class="filename">refman.tex</code> that is
202    incorrect, or will have clues at the end of the file with the dump
203    of the memory usage of LaTeX.
204  </p></li></ul></div><p>
205	  If the error at hand is not obvious after examination, a
206	  fall-back strategy is to start commenting out the doxygen
207	  input sources, which can be found in
208	  <code class="filename">doc/doxygen/user.cfg.in</code>, look for the
209	  <code class="literal">INPUT</code> tag. Start by commenting out whole
210	  directories of header files, until the offending header is
211	  identified. Then, read the latex log files to try and find
212	  surround text, and look for that in the offending header.
213	</p></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a id="doxygen.markup"></a>Markup</h4></div></div></div><p>
214	In general, libstdc++ files should be formatted according to
215	the rules found in the
216	<a class="link" href="source_code_style.html" title="Coding Style">Coding Standard</a>. Before
217	any doxygen-specific formatting tweaks are made, please try to
218	make sure that the initial formatting is sound.
219      </p><p>
220	Adding Doxygen markup to a file (informally called
221	<span class="quote">“<span class="quote">doxygenating</span>”</span>) is very simple. The Doxygen manual can be
222	found
223	<a class="link" href="http://www.stack.nl/~dimitri/doxygen/download.html#latestman" target="_top">here</a>.
224	We try to use a very-recent version of Doxygen.
225      </p><p>
226	For classes, use
227	<code class="classname">deque</code>/<code class="classname">vector</code>/<code class="classname">list</code>
228	and <code class="classname">std::pair</code> as examples.  For
229	functions, see their member functions, and the free functions
230	in <code class="filename">stl_algobase.h</code>. Member functions of
231	other container-like types should read similarly to these
232	member functions.
233      </p><p>
234	Some commentary to accompany
235	the first list in the <a class="link" href="http://www.stack.nl/~dimitri/doxygen/manual/docblocks.html" target="_top">Special
236	Documentation Blocks</a> section of the Doxygen manual:
237      </p><div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"><p>For longer comments, use the Javadoc style...</p></li><li class="listitem"><p>
238	    ...not the Qt style. The intermediate *'s are preferred.
239	  </p></li><li class="listitem"><p>
240	    Use the triple-slash style only for one-line comments (the
241	    <span class="quote">“<span class="quote">brief</span>”</span> mode).
242	  </p></li><li class="listitem"><p>
243	    This is disgusting. Don't do this.
244	  </p></li></ol></div><p>
245	Some specific guidelines:
246      </p><p>
247	Use the @-style of commands, not the !-style. Please be
248	careful about whitespace in your markup comments. Most of the
249	time it doesn't matter; doxygen absorbs most whitespace, and
250	both HTML and *roff are agnostic about whitespace. However,
251	in &lt;pre&gt; blocks and @code/@endcode sections, spacing can
252	have <span class="quote">“<span class="quote">interesting</span>”</span> effects.
253      </p><p>
254	Use either kind of grouping, as
255	appropriate. <code class="filename">doxygroups.cc</code> exists for this
256	purpose. See <code class="filename">stl_iterator.h</code> for a good example
257	of the <span class="quote">“<span class="quote">other</span>”</span> kind of grouping.
258      </p><p>
259	Please use markup tags like @p and @a when referring to things
260	such as the names of function parameters. Use @e for emphasis
261	when necessary. Use @c to refer to other standard names.
262	(Examples of all these abound in the present code.)
263      </p><p>
264	Complicated math functions should use the multi-line
265	format. An example from <code class="filename">random.h</code>:
266      </p><p>
267</p><div class="literallayout"><p><br />
268/**<br />
269 * @brief A model of a linear congruential random number generator.<br />
270 *<br />
271 * @f[<br />
272 *     x_{i+1}\leftarrow(ax_{i} + c) \bmod m<br />
273 * @f]<br />
274 */<br />
275</p></div><p>
276      </p><p>
277	One area of note is the markup required for
278	<code class="literal">@file</code> markup in header files. Two details
279	are important: for filenames that have the same name in
280	multiple directories, include part of the installed path to
281	disambiguate. For example:
282      </p><p>
283</p><div class="literallayout"><p><br />
284/** @file debug/vector<br />
285 *  This file is a GNU debug extension to the Standard C++ Library.<br />
286 */<br />
287</p></div><p>
288      </p><p>
289	The other relevant detail for header files is the use of a
290	libstdc++-specific doxygen alias that helps distinguish
291	between public header files (like <code class="filename">random</code>)
292	from implementation or private header files (like
293	<code class="filename">bits/c++config.h</code>.) This alias is spelled
294	<code class="literal">@headername</code> and can take one or two
295	arguments that detail the public header file or files that
296	should be included to use the contents of the file. All header
297	files that are not intended for direct inclusion must use
298	<code class="literal">headername</code> in the <code class="literal">file</code>
299	block. An example:
300      </p><p>
301</p><div class="literallayout"><p><br />
302/** @file bits/basic_string.h<br />
303 *  This is an internal header file, included by other library headers.<br />
304 *  Do not attempt to use it directly. @headername{string}<br />
305 */<br />
306</p></div><p>
307      </p><p>
308	Be careful about using certain, special characters when
309	writing Doxygen comments. Single and double quotes, and
310	separators in filenames are two common trouble spots. When in
311	doubt, consult the following table.
312      </p><div class="table"><a id="idm269993294592"></a><p class="title"><strong>Table B.2. HTML to Doxygen Markup Comparison</strong></p><div class="table-contents"><table summary="HTML to Doxygen Markup Comparison" border="1"><colgroup><col align="left" class="c1" /><col align="left" class="c2" /></colgroup><thead><tr><th align="left">HTML</th><th align="left">Doxygen</th></tr></thead><tbody><tr><td align="left">\</td><td align="left">\\</td></tr><tr><td align="left">"</td><td align="left">\"</td></tr><tr><td align="left">'</td><td align="left">\'</td></tr><tr><td align="left">&lt;i&gt;</td><td align="left">@a word</td></tr><tr><td align="left">&lt;b&gt;</td><td align="left">@b word</td></tr><tr><td align="left">&lt;code&gt;</td><td align="left">@c word</td></tr><tr><td align="left">&lt;em&gt;</td><td align="left">@a word</td></tr><tr><td align="left">&lt;em&gt;</td><td align="left">&lt;em&gt;two words or more&lt;/em&gt;</td></tr></tbody></table></div></div><br class="table-break" /></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="doc.docbook"></a>Docbook</h3></div></div></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a id="docbook.prereq"></a>Prerequisites</h4></div></div></div><div class="table"><a id="idm269993275152"></a><p class="title"><strong>Table B.3. Docbook Prerequisites</strong></p><div class="table-contents"><table summary="Docbook Prerequisites" border="1"><colgroup><col align="center" class="c1" /><col align="center" class="c2" /><col align="center" class="c3" /></colgroup><thead><tr><th align="center">Tool</th><th align="center">Version</th><th align="center">Required By</th></tr></thead><tbody><tr><td align="center">docbook5-style-xsl</td><td align="center">1.76.1</td><td align="center">all</td></tr><tr><td align="center">xsltproc</td><td align="center">1.1.26</td><td align="center">all</td></tr><tr><td align="center">xmllint</td><td align="center">2.7.7</td><td align="center">validation</td></tr><tr><td align="center">dblatex</td><td align="center">0.3</td><td align="center">pdf output</td></tr><tr><td align="center">pdflatex</td><td align="center">2007-59</td><td align="center">pdf output</td></tr><tr><td align="center">docbook2X</td><td align="center">0.8.8</td><td align="center">info output</td></tr><tr><td align="center">epub3 stylesheets</td><td align="center">b3</td><td align="center">epub output</td></tr></tbody></table></div></div><br class="table-break" /><p>
313	Editing the DocBook sources requires an XML editor. Many
314	exist: some notable options
315	include <span class="command"><strong>emacs</strong></span>, <span class="application">Kate</span>,
316	or <span class="application">Conglomerate</span>.
317      </p><p>
318	Some editors support special <span class="quote">“<span class="quote">XML Validation</span>”</span>
319	modes that can validate the file as it is
320	produced. Recommended is the <span class="command"><strong>nXML Mode</strong></span>
321	for <span class="command"><strong>emacs</strong></span>.
322      </p><p>
323	Besides an editor, additional DocBook files and XML tools are
324	also required.
325      </p><p>
326	Access to the DocBook 5.0 stylesheets and schema is required. The
327	stylesheets are usually packaged by vendor, in something
328	like <code class="filename">docbook5-style-xsl</code>. To exactly match
329	generated output, please use a version of the stylesheets
330	equivalent
331	to <code class="filename">docbook5-style-xsl-1.75.2-3</code>. The
332	installation directory for this package corresponds to
333	the <code class="literal">XSL_STYLE_DIR</code>
334	in <code class="filename">doc/Makefile.am</code> and defaults
335	to <code class="filename">/usr/share/sgml/docbook/xsl-ns-stylesheets</code>.
336      </p><p>
337	For processing XML, an XSLT processor and some style
338	sheets are necessary. Defaults are <span class="command"><strong>xsltproc</strong></span>
339	provided by <code class="filename">libxslt</code>.
340      </p><p>
341	For validating the XML document, you'll need
342	something like <span class="command"><strong>xmllint</strong></span> and access to the
343	relevant DocBook schema. These are provided
344	by a vendor package like <code class="filename">libxml2</code> and <code class="filename">docbook5-schemas-5.0-4</code>
345      </p><p>
346	For PDF output, something that transforms valid Docbook XML to PDF is
347	required. Possible solutions include <a class="link" href="http://dblatex.sourceforge.net" target="_top">dblatex</a>,
348	<span class="command"><strong>xmlto</strong></span>, or <span class="command"><strong>prince</strong></span>. Of
349	these, <span class="command"><strong>dblatex</strong></span> is the default. Other
350	options are listed on the DocBook web <a class="link" href="http://wiki.docbook.org/topic/DocBookPublishingTools" target="_top">pages</a>. Please
351	consult the <code class="email">&lt;<a class="email" href="mailto:libstdc++@gcc.gnu.org">libstdc++@gcc.gnu.org</a>&gt;</code> list when
352	preparing printed manuals for current best practice and
353	suggestions.
354      </p><p>
355	For Texinfo output, something that transforms valid Docbook
356	XML to Texinfo is required. The default choice is <a class="link" href="http://docbook2x.sourceforge.net/" target="_top">docbook2X</a>.
357      </p><p>
358	For epub output, the <a class="link" href="http://sourceforge.net/projects/docbook/files/epub3/" target="_top">stylesheets</a> for EPUB3 are required. These stylesheets are still in development. To validate the created file, <a class="link" href="https://code.google.com/p/epubcheck/" target="_top">epubcheck</a> is necessary.
359      </p></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a id="docbook.rules"></a>Generating the DocBook Files</h4></div></div></div><p>
360	The following Makefile rules generate (in order): an HTML
361	version of all the DocBook documentation, a PDF version of the
362	same, and a single XML document.  These rules are not
363	conditional! If the required tools are not found, or are the
364	wrong versions, the rule may end in an error.
365      </p><p>
366      </p><pre class="screen"><strong class="userinput"><code>make doc-html-docbook</code></strong></pre><p>
367      </p><p>
368      </p><pre class="screen"><strong class="userinput"><code>make doc-pdf-docbook</code></strong></pre><p>
369      </p><p>
370      </p><pre class="screen"><strong class="userinput"><code>make doc-xml-single-docbook</code></strong></pre><p>
371      </p><p>
372	Generated files are output into separate sub directores of
373	<code class="filename">doc/docbook/</code> in the
374	build directory, based on the output format. For instance, the
375	HTML docs will be in <code class="filename">doc/docbook/html</code>.
376      </p><p>
377	If the Docbook stylesheets are installed in a custom location,
378	one can use the variable <code class="literal">XSL_STYLE_DIR</code> to
379	override the Makefile defaults. For example:
380      </p><pre class="screen">
381	<strong class="userinput"><code>
382make <code class="literal">XSL_STYLE_DIR="/usr/share/xml/docbook/stylesheet/nwalsh"</code> doc-html-docbook
383	</code></strong>
384      </pre></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a id="docbook.debug"></a>Debugging Generation</h4></div></div></div><p>
385	  Sometimes, mis-configuration of the pre-requisite tools can
386	  lead to errors when attempting to build the
387	  documentation. Here are some of the obvious errors, and ways
388	  to fix some common issues that may appear quite cryptic.
389	</p><p>
390	  First, if using a rule like <code class="code">make pdf</code>, try to
391	  narrow down the scope of the error to either docbook
392	  (<code class="code">make doc-pdf-docbook</code>) or doxygen (<code class="code">make
393	  doc-pdf-doxygen</code>).
394	</p><p>
395	  Working on the docbook path only, closely examine the
396	  contents of the following build directory:
397	  <code class="filename">build/target/libstdc++-v3/doc/docbook/latex</code>.
398	  Pay attention to three files enclosed within, annotated as follows.
399	</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>
400   <span class="emphasis"><em>spine.tex</em></span>
401  </p><p>
402    The actual latex file, or partial latex file. This is generated
403    via <span class="command"><strong>dblatex</strong></span>, and is the LaTeX version of the
404    DocBook XML file <code class="filename">spine.xml</code>. Go to a specific
405    line, and look at the genrated LaTeX, and try to deduce what
406    markup in <code class="filename">spine.xml</code> is causing it.
407  </p></li><li class="listitem"><p>
408   <span class="emphasis"><em>spine.out</em></span>
409  </p><p>
410    A log of the conversion from the XML form to the LaTeX form. This
411    is a linear list, from the beginning of the
412    <code class="filename">spine.xml</code> file: the last entry of this file
413    should be the end of the DocBook file. If it is truncated, then
414    you know that the last entry is the last part of the XML source
415    file that is valid. The error is after this point.
416  </p></li><li class="listitem"><p>
417   <span class="emphasis"><em>spine.log</em></span>
418  </p><p>
419    A log of the compilation of the converted LaTeX form to pdf. This
420    is a linear list, from the beginning of the
421    <code class="filename">spine.tex</code> file: the last entry of this file
422    should be the end of the LaTeX file. If it is truncated, then you
423    know that the last entry is the last part of the generated LaTeX
424    source file that is valid. Often this file contains an error with
425    a specific line number of <code class="filename">spine.tex</code> that is
426    incorrect.
427  </p></li></ul></div><p>
428	  If the error at hand is not obvious after examination, or if one
429	  encounters the inscruitable <span class="quote">“<span class="quote">Incomplete
430	  \ifmmode</span>”</span> error, a fall-back strategy is to start
431	  commenting out parts of the XML document (regardless of what
432	  this does to over-all document validity). Start by
433	  commenting out each of the largest parts of the
434	  <code class="filename">spine.xml</code> file, section by section,
435	  until the offending section is identified.
436	</p></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a id="docbook.validation"></a>Editing and Validation</h4></div></div></div><p>
437	After editing the xml sources, please make sure that the XML
438	documentation and markup is still valid. This can be
439	done easily, with the following validation rule:
440      </p><pre class="screen">
441	<strong class="userinput"><code>make doc-xml-validate-docbook</code></strong>
442      </pre><p>
443	This is equivalent to doing:
444      </p><pre class="screen">
445	<strong class="userinput"><code>
446	  xmllint --noout --valid <code class="filename">xml/index.xml</code>
447	</code></strong>
448      </pre><p>
449	Please note that individual sections and chapters of the
450	manual can be validated by substituting the file desired for
451	<code class="filename">xml/index.xml</code> in the command
452	above. Reducing scope in this manner can be helpful when
453	validation on the entire manual fails.
454      </p><p>
455	All Docbook xml sources should always validate. No excuses!
456      </p></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a id="docbook.examples"></a>File Organization and Basics</h4></div></div></div><div class="literallayout"><p><br />
457      <span class="emphasis"><em>Which files are important</em></span><br />
458<br />
459      All Docbook files are in the directory<br />
460      libstdc++-v3/doc/xml<br />
461<br />
462      Inside this directory, the files of importance:<br />
463      spine.xml	 	- index to documentation set<br />
464      manual/spine.xml  - index to manual<br />
465      manual/*.xml  	- individual chapters and sections of the manual<br />
466      faq.xml  		- index to FAQ<br />
467      api.xml  		- index to source level / API<br />
468<br />
469      All *.txml files are template xml files, i.e., otherwise empty files with<br />
470      the correct structure, suitable for filling in with new information.<br />
471<br />
472      <span class="emphasis"><em>Canonical Writing Style</em></span><br />
473<br />
474      class template<br />
475      function template<br />
476      member function template<br />
477      (via C++ Templates, Vandevoorde)<br />
478<br />
479      class in namespace std: allocator, not std::allocator<br />
480<br />
481      header file: iostream, not &lt;iostream&gt;<br />
482<br />
483<br />
484      <span class="emphasis"><em>General structure</em></span><br />
485<br />
486      &lt;set&gt;<br />
487      &lt;book&gt;<br />
488      &lt;/book&gt;<br />
489<br />
490      &lt;book&gt;<br />
491      &lt;chapter&gt;<br />
492      &lt;/chapter&gt;<br />
493      &lt;/book&gt;<br />
494<br />
495      &lt;book&gt;<br />
496      &lt;part&gt;<br />
497      &lt;chapter&gt;<br />
498      &lt;section&gt;<br />
499      &lt;/section&gt;<br />
500<br />
501      &lt;sect1&gt;<br />
502      &lt;/sect1&gt;<br />
503<br />
504      &lt;sect1&gt;<br />
505      &lt;sect2&gt;<br />
506      &lt;/sect2&gt;<br />
507      &lt;/sect1&gt;<br />
508      &lt;/chapter&gt;<br />
509<br />
510      &lt;chapter&gt;<br />
511      &lt;/chapter&gt;<br />
512      &lt;/part&gt;<br />
513      &lt;/book&gt;<br />
514<br />
515      &lt;/set&gt;<br />
516    </p></div></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a id="docbook.markup"></a>Markup By Example</h4></div></div></div><p>
517	Complete details on Docbook markup can be found in the DocBook
518	Element Reference,
519	<a class="link" href="http://www.docbook.org/tdg/en/html/part2.html" target="_top">online</a>.
520	An incomplete reference for HTML to Docbook conversion is
521	detailed in the table below.
522      </p><div class="table"><a id="idm269993197520"></a><p class="title"><strong>Table B.4. HTML to Docbook XML Markup Comparison</strong></p><div class="table-contents"><table summary="HTML to Docbook XML Markup Comparison" border="1"><colgroup><col align="left" class="c1" /><col align="left" class="c2" /></colgroup><thead><tr><th align="left">HTML</th><th align="left">Docbook</th></tr></thead><tbody><tr><td align="left">&lt;p&gt;</td><td align="left">&lt;para&gt;</td></tr><tr><td align="left">&lt;pre&gt;</td><td align="left">&lt;computeroutput&gt;, &lt;programlisting&gt;,
523	&lt;literallayout&gt;</td></tr><tr><td align="left">&lt;ul&gt;</td><td align="left">&lt;itemizedlist&gt;</td></tr><tr><td align="left">&lt;ol&gt;</td><td align="left">&lt;orderedlist&gt;</td></tr><tr><td align="left">&lt;il&gt;</td><td align="left">&lt;listitem&gt;</td></tr><tr><td align="left">&lt;dl&gt;</td><td align="left">&lt;variablelist&gt;</td></tr><tr><td align="left">&lt;dt&gt;</td><td align="left">&lt;term&gt;</td></tr><tr><td align="left">&lt;dd&gt;</td><td align="left">&lt;listitem&gt;</td></tr><tr><td align="left">&lt;a href=""&gt;</td><td align="left">&lt;ulink url=""&gt;</td></tr><tr><td align="left">&lt;code&gt;</td><td align="left">&lt;literal&gt;, &lt;programlisting&gt;</td></tr><tr><td align="left">&lt;strong&gt;</td><td align="left">&lt;emphasis&gt;</td></tr><tr><td align="left">&lt;em&gt;</td><td align="left">&lt;emphasis&gt;</td></tr><tr><td align="left">"</td><td align="left">&lt;quote&gt;</td></tr></tbody></table></div></div><br class="table-break" /><p>
524  And examples of detailed markup for which there are no real HTML
525  equivalents are listed in the table below.
526</p><div class="table"><a id="idm269993173376"></a><p class="title"><strong>Table B.5. Docbook XML Element Use</strong></p><div class="table-contents"><table summary="Docbook XML Element Use" border="1"><colgroup><col align="left" class="c1" /><col align="left" class="c2" /></colgroup><thead><tr><th align="left">Element</th><th align="left">Use</th></tr></thead><tbody><tr><td align="left">&lt;structname&gt;</td><td align="left">&lt;structname&gt;char_traits&lt;/structname&gt;</td></tr><tr><td align="left">&lt;classname&gt;</td><td align="left">&lt;classname&gt;string&lt;/classname&gt;</td></tr><tr><td align="left">&lt;function&gt;</td><td align="left">
527	<p>&lt;function&gt;clear()&lt;/function&gt;</p>
528	<p>&lt;function&gt;fs.clear()&lt;/function&gt;</p>
529      </td></tr><tr><td align="left">&lt;type&gt;</td><td align="left">&lt;type&gt;long long&lt;/type&gt;</td></tr><tr><td align="left">&lt;varname&gt;</td><td align="left">&lt;varname&gt;fs&lt;/varname&gt;</td></tr><tr><td align="left">&lt;literal&gt;</td><td align="left">
530	<p>&lt;literal&gt;-Weffc++&lt;/literal&gt;</p>
531	<p>&lt;literal&gt;rel_ops&lt;/literal&gt;</p>
532      </td></tr><tr><td align="left">&lt;constant&gt;</td><td align="left">
533	<p>&lt;constant&gt;_GNU_SOURCE&lt;/constant&gt;</p>
534	<p>&lt;constant&gt;3.0&lt;/constant&gt;</p>
535      </td></tr><tr><td align="left">&lt;command&gt;</td><td align="left">&lt;command&gt;g++&lt;/command&gt;</td></tr><tr><td align="left">&lt;errortext&gt;</td><td align="left">&lt;errortext&gt;In instantiation of&lt;/errortext&gt;</td></tr><tr><td align="left">&lt;filename&gt;</td><td align="left">
536	<p>&lt;filename class="headerfile"&gt;ctype.h&lt;/filename&gt;</p>
537	<p>&lt;filename class="directory"&gt;/home/gcc/build&lt;/filename&gt;</p>
538	<p>&lt;filename class="libraryfile"&gt;libstdc++.so&lt;/filename&gt;</p>
539      </td></tr></tbody></table></div></div><br class="table-break" /></div></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="appendix_porting.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="appendix_porting.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="internals.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Appendix B. 
540  Porting and Maintenance
541
542 </td><td width="20%" align="center"><a accesskey="h" href="../index.html">Home</a></td><td width="40%" align="right" valign="top"> Porting to New Hardware or Operating Systems</td></tr></table></div></body></html>