OSDN Git Service

7dae04eb9f38b5fb5d852710a68f6fa52d7f4fc0
[pf3gnuchains/gcc-fork.git] / libstdc++-v3 / doc / html / manual / documentation_style.html
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.74.3" /><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
5   
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" lang="en" xml:lang="en"><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" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 class="title"><a id="doc_style.doxygen"></a>Doxygen</h3></div></div></div><div class="sect3" lang="en" xml:lang="en"><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.x,
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>
17         package will need to be installed. 
18       </p></div><div class="sect3" lang="en" xml:lang="en"><div class="titlepage"><div><div><h4 class="title"><a id="doxygen.rules"></a>Generating the Doxygen Files</h4></div></div></div><p>
19         The following Makefile rules run Doxygen to generate HTML
20         docs, XML docs, and the man pages.
21       </p><p>
22       </p><pre class="screen"><strong class="userinput"><code>make doc-html-doxygen</code></strong></pre><p>
23       </p><p>
24       </p><pre class="screen"><strong class="userinput"><code>make doc-xml-doxygen</code></strong></pre><p>
25       </p><p>
26       </p><pre class="screen"><strong class="userinput"><code>make doc-man-doxygen</code></strong></pre><p>
27       </p><p>
28         Careful observers will see that the Makefile rules simply call
29         a script from the source tree, <code class="filename">run_doxygen</code>, which
30         does the actual work of running Doxygen and then (most
31         importantly) massaging the output files. If for some reason
32         you prefer to not go through the Makefile, you can call this
33         script directly. (Start by passing <code class="literal">--help</code>.)
34       </p><p>
35         If you wish to tweak the Doxygen settings, do so by editing
36         <code class="filename">doc/doxygen/user.cfg.in</code>. Notes to fellow
37         library hackers are written in triple-# comments.
38       </p></div><div class="sect3" lang="en" xml:lang="en"><div class="titlepage"><div><div><h4 class="title"><a id="doxygen.markup"></a>Markup</h4></div></div></div><p>
39         In general, libstdc++ files should be formatted according to
40         the rules found in the
41         <a class="link" href="source_code_style.html" title="Coding Style">Coding Standard</a>. Before
42         any doxygen-specific formatting tweaks are made, please try to
43         make sure that the initial formatting is sound.
44       </p><p>
45         Adding Doxygen markup to a file (informally called
46         “<span class="quote">doxygenating</span>”) is very simple. The Doxygen manual can be
47         found
48         <a class="ulink" href="http://www.stack.nl/~dimitri/doxygen/download.html#latestman" target="_top">here</a>.
49         We try to use a very-recent version of Doxygen.
50       </p><p>
51         For classes, use
52         <code class="classname">deque</code>/<code class="classname">vector</code>/<code class="classname">list</code>
53         and <code class="classname">std::pair</code> as examples.  For
54         functions, see their member functions, and the free functions
55         in <code class="filename">stl_algobase.h</code>. Member functions of
56         other container-like types should read similarly to these
57         member functions.
58       </p><p>
59         These points accompany the first list in section 3.1 of the
60         Doxygen manual:
61       </p><div class="orderedlist"><ol type="1"><li><p>Use the Javadoc style...</p></li><li><p>
62             ...not the Qt style. The intermediate *'s are preferred.
63           </p></li><li><p>
64             Use the triple-slash style only for one-line comments (the
65             “<span class="quote">brief</span>” mode).  Very recent versions of Doxygen permit
66             full-mode comments in triple-slash blocks, but the
67             formatting still comes out wonky.
68           </p></li><li><p>
69             This is disgusting. Don't do this.
70           </p></li></ol></div><p>
71         Use the @-style of commands, not the !-style. Please be
72         careful about whitespace in your markup comments. Most of the
73         time it doesn't matter; doxygen absorbs most whitespace, and
74         both HTML and *roff are agnostic about whitespace. However,
75         in &lt;pre&gt; blocks and @code/@endcode sections, spacing can
76         have “<span class="quote">interesting</span>” effects.
77       </p><p>
78         Use either kind of grouping, as
79         appropriate. <code class="filename">doxygroups.cc</code> exists for this
80         purpose. See <code class="filename">stl_iterator.h</code> for a good example
81         of the “<span class="quote">other</span>” kind of grouping.
82       </p><p>
83         Please use markup tags like @p and @a when referring to things
84         such as the names of function parameters. Use @e for emphasis
85         when necessary. Use @c to refer to other standard names.
86         (Examples of all these abound in the present code.)
87       </p></div></div><div class="sect2" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 class="title"><a id="doc_style.docbook"></a>Docbook</h3></div></div></div><div class="sect3" lang="en" xml:lang="en"><div class="titlepage"><div><div><h4 class="title"><a id="docbook.prereq"></a>Prerequisites</h4></div></div></div><p>
88         Editing the DocBook sources requires an XML editor. Many
89         exist: some notable options
90         include <span class="command"><strong>emacs</strong></span>, <span class="application">Kate</span>,
91         or <span class="application">Conglomerate</span>.
92       </p><p>
93         Some editors support special “<span class="quote">XML Validation</span>”
94         modes that can validate the file as it is
95         produced. Recommended is the <span class="command"><strong>nXML Mode</strong></span>
96         for <span class="command"><strong>emacs</strong></span>.
97       </p><p>
98         Besides an editor, additional DocBook files and XML tools are
99         also required.
100       </p><p>
101         Access to the DocBook stylesheets and DTD is required. The
102         stylesheets are usually packaged by vendor, in something
103         like <code class="filename">docbook-style-xsl</code>. To exactly match
104         generated output, please use a version of the stylesheets
105         equivalent
106         to <code class="filename">docbook-style-xsl-1.74.0-5</code>. The
107         installation directory for this package corresponds to
108         the <code class="literal">XSL_STYLE_DIR</code>
109         in <code class="filename">doc/Makefile.am</code> and defaults
110         to <code class="filename">/usr/share/sgml/docbook/xsl-stylesheets</code>.
111       </p><p>
112         For processing XML, an XML processor and some style
113         sheets are necessary. Defaults are <span class="command"><strong>xsltproc</strong></span>
114         provided by <code class="filename">libxslt</code>.
115       </p><p>
116         For validating the XML document, you'll need
117         something like <span class="command"><strong>xmllint</strong></span> and access to the
118         DocBook DTD. These are provided
119         by a vendor package like <code class="filename">libxml2</code>.
120       </p><p>
121         For PDF output, something that transforms valid XML to PDF is
122         required. Possible solutions include <span class="command"><strong>xmlto</strong></span>,
123         <a class="ulink" href="http://xmlgraphics.apache.org/fop/" target="_top">Apache
124         FOP</a>, or <span class="command"><strong>prince</strong></span>. Other options are
125         listed on the DocBook web <a class="ulink" href="http://wiki.docbook.org/topic/DocBookPublishingTools" target="_top">pages</a>. Please
126         consult the <code class="email">&lt;<a class="email" href="mailto:libstdc++@gcc.gnu.org">libstdc++@gcc.gnu.org</a>&gt;</code> list when
127         preparing printed manuals for current best practice and suggestions.
128       </p><p>
129         Make sure that the XML documentation and markup is valid for
130         any change. This can be done easily, with the validation rules
131         in the <code class="filename">Makefile</code>, which is equivalent to doing: 
132       </p><pre class="screen">
133           <strong class="userinput"><code>
134 xmllint --noout --valid <code class="filename">xml/index.xml</code>
135           </code></strong>
136         </pre></div><div class="sect3" lang="en" xml:lang="en"><div class="titlepage"><div><div><h4 class="title"><a id="docbook.rules"></a>Generating the DocBook Files</h4></div></div></div><p>
137         The following Makefile rules generate (in order): an HTML
138         version of all the documentation, a PDF version of the same, a
139         single XML document, and the result of validating the entire XML
140         document.
141       </p><p>
142       </p><pre class="screen"><strong class="userinput"><code>make doc-html</code></strong></pre><p>
143       </p><p>
144       </p><pre class="screen"><strong class="userinput"><code>make doc-pdf</code></strong></pre><p>
145       </p><p>
146       </p><pre class="screen"><strong class="userinput"><code>make doc-xml-single</code></strong></pre><p>
147       </p><p>
148       </p><pre class="screen"><strong class="userinput"><code>make doc-xml-validate</code></strong></pre><p>
149       </p></div><div class="sect3" lang="en" xml:lang="en"><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 />
150       <span class="emphasis"><em>Which files are important</em></span><br />
151 <br />
152       All Docbook files are in the directory<br />
153       libstdc++-v3/doc/xml<br />
154 <br />
155       Inside this directory, the files of importance:<br />
156       spine.xml         - index to documentation set<br />
157       manual/spine.xml  - index to manual<br />
158       manual/*.xml      - individual chapters and sections of the manual<br />
159       faq.xml           - index to FAQ<br />
160       api.xml           - index to source level / API <br />
161 <br />
162       All *.txml files are template xml files, i.e., otherwise empty files with<br />
163       the correct structure, suitable for filling in with new information.<br />
164 <br />
165       <span class="emphasis"><em>Canonical Writing Style</em></span><br />
166 <br />
167       class template<br />
168       function template<br />
169       member function template<br />
170       (via C++ Templates, Vandevoorde)<br />
171 <br />
172       class in namespace std: allocator, not std::allocator<br />
173 <br />
174       header file: iostream, not &lt;iostream&gt;<br />
175 <br />
176 <br />
177       <span class="emphasis"><em>General structure</em></span><br />
178 <br />
179       &lt;set&gt;<br />
180       &lt;book&gt;<br />
181       &lt;/book&gt;<br />
182 <br />
183       &lt;book&gt;<br />
184       &lt;chapter&gt;<br />
185       &lt;/chapter&gt;<br />
186       &lt;/book&gt;<br />
187 <br />
188       &lt;book&gt;        <br />
189       &lt;part&gt;<br />
190       &lt;chapter&gt;<br />
191       &lt;section&gt;<br />
192       &lt;/section&gt;<br />
193 <br />
194       &lt;sect1&gt;<br />
195       &lt;/sect1&gt;<br />
196 <br />
197       &lt;sect1&gt;<br />
198       &lt;sect2&gt;<br />
199       &lt;/sect2&gt;<br />
200       &lt;/sect1&gt;<br />
201       &lt;/chapter&gt;<br />
202 <br />
203       &lt;chapter&gt;<br />
204       &lt;/chapter&gt;<br />
205       &lt;/part&gt;  <br />
206       &lt;/book&gt;<br />
207 <br />
208       &lt;/set&gt;<br />
209     </p></div></div><div class="sect3" lang="en" xml:lang="en"><div class="titlepage"><div><div><h4 class="title"><a id="docbook.markup"></a>Markup By Example</h4></div></div></div><p>
210 Complete details on Docbook markup can be found in the DocBook Element
211 Reference, <a class="ulink" href="http://www.docbook.org/tdg/en/html/part2.html" target="_top">online</a>. An
212 incomplete reference for HTML to Docbook conversion is detailed in the
213 table below.
214 </p><div class="table"><a id="id449698"></a><p class="title"><b>Table A.1. 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">XML</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;, 
215         &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>
216   And examples of detailed markup for which there are no real HTML
217   equivalents are listed in the table below.
218 </p><div class="table"><a id="id475153"></a><p class="title"><b>Table A.2. 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">
219         <p>&lt;function&gt;clear()&lt;/function&gt;</p>
220         <p>&lt;function&gt;fs.clear()&lt;/function&gt;</p>
221       </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">
222         <p>&lt;literal&gt;-Weffc++&lt;/literal&gt;</p>
223         <p>&lt;literal&gt;rel_ops&lt;/literal&gt;</p>
224       </td></tr><tr><td align="left">&lt;constant&gt;</td><td align="left">
225         <p>&lt;constant&gt;_GNU_SOURCE&lt;/constant&gt;</p>
226         <p>&lt;constant&gt;3.0&lt;/constant&gt;</p>
227       </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">
228         <p>&lt;filename class="headerfile"&gt;ctype.h&lt;/filename&gt;</p>
229         <p>&lt;filename class="directory"&gt;/home/gcc/build&lt;/filename&gt;</p>
230       </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="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>