Merged r158704 through r158906 into branch.
[official-gcc.git] / libstdc++-v3 / doc / html / manual / documentation_style.html
blob8292e2531657f8ea09a124871b1dfa4abbde3fe2
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">
3 <html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Documentation Style</title><meta name="generator" content="DocBook XSL Stylesheets V1.75.2" /><meta name="keywords" content="&#10; ISO C++&#10; , &#10; library&#10; " /><link rel="home" href="../spine.html" title="The GNU C++ Library Documentation" /><link rel="up" href="appendix_contributing.html" title="Appendix A.  Contributing" /><link rel="prev" href="source_code_style.html" title="Coding Style" /><link rel="next" href="source_design_notes.html" title="Design Notes" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Documentation Style</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="source_code_style.html">Prev</a> </td><th width="60%" align="center">Appendix A. 
4 Contributing
6 </th><td width="20%" align="right"> <a accesskey="n" href="source_design_notes.html">Next</a></td></tr></table><hr /></div><div class="sect1" title="Documentation Style"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="contrib.doc_style"></a>Documentation Style</h2></div></div></div><div class="sect2" title="Doxygen"><div class="titlepage"><div><div><h3 class="title"><a id="doc_style.doxygen"></a>Doxygen</h3></div></div></div><div class="sect3" title="Prerequisites"><div class="titlepage"><div><div><h4 class="title"><a id="doxygen.prereq"></a>Prerequisites</h4></div></div></div><p>
7 Prerequisite tools are Bash 2.0 or later,
8 <a class="ulink" href="http://www.doxygen.org/" target="_top">Doxygen</a>, and
9 the <a class="ulink" href="http://www.gnu.org/software/coreutils/" target="_top">GNU
10 coreutils</a>. (GNU versions of find, xargs, and possibly
11 sed and grep are used, just because the GNU versions make
12 things very easy.)
13 </p><p>
14 To generate the pretty pictures and hierarchy
15 graphs, the
16 <a class="ulink" href="http://www.graphviz.org" target="_top">Graphviz</a> package
17 will need to be installed. For PDF
18 output, <a class="ulink" href="http://www.tug.org/applications/pdftex/" target="_top">
19 pdflatex</a> is required.
20 </p></div><div class="sect3" title="Generating the Doxygen Files"><div class="titlepage"><div><div><h4 class="title"><a id="doxygen.rules"></a>Generating the Doxygen Files</h4></div></div></div><p>
21 The following Makefile rules run Doxygen to generate HTML
22 docs, XML docs, PDF docs, and the man pages.
23 </p><p>
24 </p><pre class="screen"><strong class="userinput"><code>make doc-html-doxygen</code></strong></pre><p>
25 </p><p>
26 </p><pre class="screen"><strong class="userinput"><code>make doc-xml-doxygen</code></strong></pre><p>
27 </p><p>
28 </p><pre class="screen"><strong class="userinput"><code>make doc-pdf-doxygen</code></strong></pre><p>
29 </p><p>
30 </p><pre class="screen"><strong class="userinput"><code>make doc-man-doxygen</code></strong></pre><p>
31 </p><p>
32 Careful observers will see that the Makefile rules simply call
33 a script from the source tree, <code class="filename">run_doxygen</code>, which
34 does the actual work of running Doxygen and then (most
35 importantly) massaging the output files. If for some reason
36 you prefer to not go through the Makefile, you can call this
37 script directly. (Start by passing <code class="literal">--help</code>.)
38 </p><p>
39 If you wish to tweak the Doxygen settings, do so by editing
40 <code class="filename">doc/doxygen/user.cfg.in</code>. Notes to fellow
41 library hackers are written in triple-# comments.
42 </p></div><div class="sect3" title="Markup"><div class="titlepage"><div><div><h4 class="title"><a id="doxygen.markup"></a>Markup</h4></div></div></div><p>
43 In general, libstdc++ files should be formatted according to
44 the rules found in the
45 <a class="link" href="source_code_style.html" title="Coding Style">Coding Standard</a>. Before
46 any doxygen-specific formatting tweaks are made, please try to
47 make sure that the initial formatting is sound.
48 </p><p>
49 Adding Doxygen markup to a file (informally called
50 <span class="quote"><span class="quote">doxygenating</span></span>) is very simple. The Doxygen manual can be
51 found
52 <a class="ulink" href="http://www.stack.nl/~dimitri/doxygen/download.html#latestman" target="_top">here</a>.
53 We try to use a very-recent version of Doxygen.
54 </p><p>
55 For classes, use
56 <code class="classname">deque</code>/<code class="classname">vector</code>/<code class="classname">list</code>
57 and <code class="classname">std::pair</code> as examples. For
58 functions, see their member functions, and the free functions
59 in <code class="filename">stl_algobase.h</code>. Member functions of
60 other container-like types should read similarly to these
61 member functions.
62 </p><p>
63 Some commentary to accompany
64 the first list in the <a class="ulink" href="http://www.stack.nl/~dimitri/doxygen/docblocks.html" target="_top">Special
65 Documentation Blocks</a> section of
66 the Doxygen manual:
67 </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>
68 ...not the Qt style. The intermediate *'s are preferred.
69 </p></li><li class="listitem"><p>
70 Use the triple-slash style only for one-line comments (the
71 <span class="quote"><span class="quote">brief</span></span> mode).
72 </p></li><li class="listitem"><p>
73 This is disgusting. Don't do this.
74 </p></li></ol></div><p>
75 Some specific guidelines:
76 </p><p>
77 Use the @-style of commands, not the !-style. Please be
78 careful about whitespace in your markup comments. Most of the
79 time it doesn't matter; doxygen absorbs most whitespace, and
80 both HTML and *roff are agnostic about whitespace. However,
81 in &lt;pre&gt; blocks and @code/@endcode sections, spacing can
82 have <span class="quote"><span class="quote">interesting</span></span> effects.
83 </p><p>
84 Use either kind of grouping, as
85 appropriate. <code class="filename">doxygroups.cc</code> exists for this
86 purpose. See <code class="filename">stl_iterator.h</code> for a good example
87 of the <span class="quote"><span class="quote">other</span></span> kind of grouping.
88 </p><p>
89 Please use markup tags like @p and @a when referring to things
90 such as the names of function parameters. Use @e for emphasis
91 when necessary. Use @c to refer to other standard names.
92 (Examples of all these abound in the present code.)
93 </p><p>
94 Complicated math functions should use the multi-line
95 format. An example from <code class="filename">random.h</code>:
96 </p><p>
97 </p><div class="literallayout"><p><br />
98   /**<br />
99    * @brief A model of a linear congruential random number generator.<br />
100    *<br />
101    * @f[<br />
102    *     x_{i+1}\leftarrow(ax_{i} + c) \bmod m<br />
103    * @f]<br />
104    */<br />
105 </p></div><p>
106 </p><p>
107 Be careful about using certain, special characters when
108 writing Doxygen comments. Single and double quotes, and
109 separators in filenames are two common trouble spots. When in
110 doubt, consult the following table.
111 </p><div class="table"><a id="id569176"></a><p class="title"><b>Table A.1. HTML to Doxygen Markup Comparison</b></p><div class="table-contents"><table summary="HTML to Doxygen Markup Comparison" border="1"><colgroup><col align="left" /><col align="left" /></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="sect2" title="Docbook"><div class="titlepage"><div><div><h3 class="title"><a id="doc_style.docbook"></a>Docbook</h3></div></div></div><div class="sect3" title="Prerequisites"><div class="titlepage"><div><div><h4 class="title"><a id="docbook.prereq"></a>Prerequisites</h4></div></div></div><p>
112 Editing the DocBook sources requires an XML editor. Many
113 exist: some notable options
114 include <span class="command"><strong>emacs</strong></span>, <span class="application">Kate</span>,
115 or <span class="application">Conglomerate</span>.
116 </p><p>
117 Some editors support special <span class="quote"><span class="quote">XML Validation</span></span>
118 modes that can validate the file as it is
119 produced. Recommended is the <span class="command"><strong>nXML Mode</strong></span>
120 for <span class="command"><strong>emacs</strong></span>.
121 </p><p>
122 Besides an editor, additional DocBook files and XML tools are
123 also required.
124 </p><p>
125 Access to the DocBook stylesheets and DTD is required. The
126 stylesheets are usually packaged by vendor, in something
127 like <code class="filename">docbook-style-xsl</code>. To exactly match
128 generated output, please use a version of the stylesheets
129 equivalent
130 to <code class="filename">docbook-style-xsl-1.74.0-5</code>. The
131 installation directory for this package corresponds to
132 the <code class="literal">XSL_STYLE_DIR</code>
133 in <code class="filename">doc/Makefile.am</code> and defaults
134 to <code class="filename">/usr/share/sgml/docbook/xsl-stylesheets</code>.
135 </p><p>
136 For processing XML, an XML processor and some style
137 sheets are necessary. Defaults are <span class="command"><strong>xsltproc</strong></span>
138 provided by <code class="filename">libxslt</code>.
139 </p><p>
140 For validating the XML document, you'll need
141 something like <span class="command"><strong>xmllint</strong></span> and access to the
142 DocBook DTD. These are provided
143 by a vendor package like <code class="filename">libxml2</code>.
144 </p><p>
145 For PDF output, something that transforms valid XML to PDF is
146 required. Possible solutions include
147 <a class="ulink" href="http://dblatex.sourceforge.net" target="_top">dblatex</a>,
148 <span class="command"><strong>xmlto</strong></span>, or <span class="command"><strong>prince</strong></span>. Other
149 options are listed on the DocBook
150 web <a class="ulink" href="http://wiki.docbook.org/topic/DocBookPublishingTools" target="_top">pages</a>. Please
151 consult the <code class="email">&lt;<a class="email" href="mailto:libstdc++@gcc.gnu.org">libstdc++@gcc.gnu.org</a>&gt;</code> list when
152 preparing printed manuals for current best practice and
153 suggestions.
154 </p><p>
155 Make sure that the XML documentation and markup is valid for
156 any change. This can be done easily, with the validation rules
157 in the <code class="filename">Makefile</code>, which is equivalent to doing:
158 </p><pre class="screen">
159 <strong class="userinput"><code>
160 xmllint --noout --valid <code class="filename">xml/index.xml</code>
161 </code></strong>
162 </pre></div><div class="sect3" title="Generating the DocBook Files"><div class="titlepage"><div><div><h4 class="title"><a id="docbook.rules"></a>Generating the DocBook Files</h4></div></div></div><p>
163 The following Makefile rules generate (in order): an HTML
164 version of all the DocBook documentation, a PDF version of the same, a
165 single XML document, and the result of validating the entire XML
166 document.
167 </p><p>
168 </p><pre class="screen"><strong class="userinput"><code>make doc-html-docbook</code></strong></pre><p>
169 </p><p>
170 </p><pre class="screen"><strong class="userinput"><code>make doc-pdf-docbook</code></strong></pre><p>
171 </p><p>
172 </p><pre class="screen"><strong class="userinput"><code>make doc-xml-single-docbook</code></strong></pre><p>
173 </p><p>
174 </p><pre class="screen"><strong class="userinput"><code>make doc-xml-validate-docbook</code></strong></pre><p>
175 </p></div><div class="sect3" title="File Organization and Basics"><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 />
176       <span class="emphasis"><em>Which files are important</em></span><br />
177 <br />
178       All Docbook files are in the directory<br />
179       libstdc++-v3/doc/xml<br />
180 <br />
181       Inside this directory, the files of importance:<br />
182       spine.xml   - index to documentation set<br />
183       manual/spine.xml  - index to manual<br />
184       manual/*.xml   - individual chapters and sections of the manual<br />
185       faq.xml   - index to FAQ<br />
186       api.xml   - index to source level / API<br />
187 <br />
188       All *.txml files are template xml files, i.e., otherwise empty files with<br />
189       the correct structure, suitable for filling in with new information.<br />
190 <br />
191       <span class="emphasis"><em>Canonical Writing Style</em></span><br />
192 <br />
193       class template<br />
194       function template<br />
195       member function template<br />
196       (via C++ Templates, Vandevoorde)<br />
197 <br />
198       class in namespace std: allocator, not std::allocator<br />
199 <br />
200       header file: iostream, not &lt;iostream&gt;<br />
201 <br />
202 <br />
203       <span class="emphasis"><em>General structure</em></span><br />
204 <br />
205       &lt;set&gt;<br />
206       &lt;book&gt;<br />
207       &lt;/book&gt;<br />
208 <br />
209       &lt;book&gt;<br />
210       &lt;chapter&gt;<br />
211       &lt;/chapter&gt;<br />
212       &lt;/book&gt;<br />
213 <br />
214       &lt;book&gt;<br />
215       &lt;part&gt;<br />
216       &lt;chapter&gt;<br />
217       &lt;section&gt;<br />
218       &lt;/section&gt;<br />
219 <br />
220       &lt;sect1&gt;<br />
221       &lt;/sect1&gt;<br />
222 <br />
223       &lt;sect1&gt;<br />
224       &lt;sect2&gt;<br />
225       &lt;/sect2&gt;<br />
226       &lt;/sect1&gt;<br />
227       &lt;/chapter&gt;<br />
228 <br />
229       &lt;chapter&gt;<br />
230       &lt;/chapter&gt;<br />
231       &lt;/part&gt;<br />
232       &lt;/book&gt;<br />
233 <br />
234       &lt;/set&gt;<br />
235     </p></div></div><div class="sect3" title="Markup By Example"><div class="titlepage"><div><div><h4 class="title"><a id="docbook.markup"></a>Markup By Example</h4></div></div></div><p>
236 Complete details on Docbook markup can be found in the DocBook
237 Element Reference,
238 <a class="ulink" href="http://www.docbook.org/tdg/en/html/part2.html" target="_top">online</a>.
239 An incomplete reference for HTML to Docbook conversion is
240 detailed in the table below.
241 </p><div class="table"><a id="id662369"></a><p class="title"><b>Table A.2. HTML to Docbook XML Markup Comparison</b></p><div class="table-contents"><table summary="HTML to Docbook XML Markup Comparison" border="1"><colgroup><col align="left" /><col align="left" /></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;,
242 &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>
243 And examples of detailed markup for which there are no real HTML
244 equivalents are listed in the table below.
245 </p><div class="table"><a id="id640551"></a><p class="title"><b>Table A.3. Docbook XML Element Use</b></p><div class="table-contents"><table summary="Docbook XML Element Use" border="1"><colgroup><col align="left" /><col align="left" /></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">
246 <p>&lt;function&gt;clear()&lt;/function&gt;</p>
247 <p>&lt;function&gt;fs.clear()&lt;/function&gt;</p>
248 </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">
249 <p>&lt;literal&gt;-Weffc++&lt;/literal&gt;</p>
250 <p>&lt;literal&gt;rel_ops&lt;/literal&gt;</p>
251 </td></tr><tr><td align="left">&lt;constant&gt;</td><td align="left">
252 <p>&lt;constant&gt;_GNU_SOURCE&lt;/constant&gt;</p>
253 <p>&lt;constant&gt;3.0&lt;/constant&gt;</p>
254 </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">
255 <p>&lt;filename class="headerfile"&gt;ctype.h&lt;/filename&gt;</p>
256 <p>&lt;filename class="directory"&gt;/home/gcc/build&lt;/filename&gt;</p>
257 <p>&lt;filename class="libraryfile"&gt;libstdc++.so&lt;/filename&gt;</p>
258 </td></tr></tbody></table></div></div><br class="table-break" /></div></div><div class="sect2" title="Combines"><div class="titlepage"><div><div><h3 class="title"><a id="doc_style.combines"></a>Combines</h3></div></div></div><div class="sect3" title="Generating Combines and Assemblages"><div class="titlepage"><div><div><h4 class="title"><a id="combines.rules"></a>Generating Combines and Assemblages</h4></div></div></div><p>
259 The following Makefile rules are defaults, and are usually
260 aliased to variable rules.
261 </p><p>
262 </p><pre class="screen"><strong class="userinput"><code>make doc-html</code></strong></pre><p>
263 </p><p>
264 </p><pre class="screen"><strong class="userinput"><code>make doc-man</code></strong></pre><p>
265 </p><p>
266 </p><pre class="screen"><strong class="userinput"><code>make doc-pdf</code></strong></pre><p>
267 </p></div></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="source_code_style.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="appendix_contributing.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="source_design_notes.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Coding Style </td><td width="20%" align="center"><a accesskey="h" href="../spine.html">Home</a></td><td width="40%" align="right" valign="top"> Design Notes</td></tr></table></div></body></html>