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