]> git.saurik.com Git - wxWidgets.git/blame - docs/tech/tn0003.txt
fixing link anchors naming
[wxWidgets.git] / docs / tech / tn0003.txt
CommitLineData
fc2171bd 1 Adding wxWidgets class documentation
12646a5a
JS
2 ====================================
3
4This note is aimed at people wishing to add documentation for a
fc2171bd 5class to either the main wxWidgets manual, or to their own
12646a5a
JS
6manual.
7
209f9b5e
FM
8wxWidgets uses Doxygen to process header input files with embedded
9documentation in the form of C++ comments and output in HTML, and XML
10(Doxygen itself can also output Latex, manpages, RTF, PDF etc).
11See http://www.doxygen.org for more info about Doxygen.
12646a5a 12
209f9b5e
FM
13If you want to add documentation of a new class/function to the
14existing manual in docs/doxygen, you need to create a new .h file,
15e.g. myclass.h, under the interface folder, which contains the public
16interface of the new class/function in C++ syntax.
17The documentation can then be added in form of Doxygen comments to
18the header file.
12646a5a 19
209f9b5e
FM
20You may also want to write a separate topic file,
21e.g. docs/doxygen/overviews/myclass.h, and add the entry to
22docs/doxygen/mainpages/topics.h.
12646a5a 23
209f9b5e 24If applicable, also add an entry to docs/doxygen/mainpages/categories.h.
12646a5a 25
209f9b5e
FM
26You can generate a first raw version of myclass.h simply taking its
27"real" header and removing all the private and protected sections and
28in general removing everything the user "shouldn't know": i.e. all things
29which are implementation details.
12646a5a 30
12646a5a 31
209f9b5e
FM
32Running Doxygen
33===============
12646a5a 34
209f9b5e 35First, make sure you have a recent version of Doxygen installed in your system.
3ca6a5f0 36
209f9b5e 37For HTML:
3ca6a5f0 38
209f9b5e
FM
39 1) cd wxWidgets/docs/doxygen
40 2) run ./regen.sh [Unix] or regen.bat [Windows]
3ca6a5f0 41
209f9b5e 42[TODO: istructions for generation of other formats]
12646a5a 43
12646a5a
JS
44
45Important Dos and Don'ts
46========================
47
48DO:
49
209f9b5e
FM
50- Doxygen supports both commands in the form \command and @command;
51 all wxWidgets documentation uses the @command form.
52
53- strive to use dedicated Doxygen commands for e.g. notes, lists,
54 sections, etc. The "Special commands" page:
55 http://www.stack.nl/~dimitri/doxygen/commands.html
56 is your friend!
57 It's also very important to make a consistent use of the ALIASES
58 defined by wxWidgets' Doxyfile. Open that file for more info.
12646a5a 59
209f9b5e
FM
60- when you write true, false and NULL with their C++ semantic meaning,
61 then use the @true, @false and @NULL commands.
12646a5a 62
209f9b5e
FM
63- separe different paragraphs with an empty comment line.
64 This is important otherwise Doxygen puts everything in the same
65 paragraph making the result less readable.
12646a5a 66
209f9b5e
FM
67- leave a blank comment line between a @section, @subsection, @page
68 and the next paragraph.
12646a5a 69
209f9b5e
FM
70- test your changes, both reading the generated HTML docs and by looking
71 at the "doxygen.log" file produced (which will warn you about any
72 eventual mistake found in the comments).
12646a5a 73
209f9b5e 74- quote all the following characters prefixing them with a "@" char:
b74d0665 75
209f9b5e 76 @ $ \ & < > # %
b74d0665 77
209f9b5e
FM
78- when using a Doxygen alias like @itemdef{}, you need to escape the
79 comma characters which appear on the first argument, otherwise Doxygen
80 will interpret them as the marker of the end of the first argument and
81 the beginning of the second argument's text.
82
83 E.g. if you want to define the item "wxEVT_MACRO(id, func)" you need to
84 write:
85 @itemdef{wxEVT_MACRO(id\, func), This is the description of the macro}
86
87 Also note that you need to escape only the commas of the first argument's text;
88 second argument can have up to 10 commas unescaped (see the Doxyfile for the
89 trick used to implement this).
b74d0665 90
12646a5a
JS
91DON'T:
92
93- use jargon, such as 'gonna', or omit the definite article.
94 The manual is intended to be a fluent, English document and
95 not a collection of rough notes.
96
209f9b5e 97- use non-alphanumeric characters in link anchors.
12646a5a 98
c03100c3
FM
99- use Doxygen @b @c @e commands when referring to more than a single word;
100 in that case you need to use the <b>...</b>, <tt>...</tt>, <em>...</em>
101 HTML-style tags instead
102
103- use HTML style tags for creation of tables or lists.
104 Use wx aliases instead like @beginTable, @row2col, @row3col, @endTable and
105 @beginDefList, @itemdef, @endDefList, etc.
106 See the Doxyfile for more info.
107
12646a5a 108
209f9b5e
FM
109Documentation comment for a class
110=================================
12646a5a
JS
111
112Start off with:
113
209f9b5e
FM
114/**
115 * @class wxMyClass
116 * @headerfile wx/myclass.h
117 *
118 * ...here goes the description...
119 *
120 * @beginEventTable
121 * @event{EVT_SOME_EVENT(id, func)}:
122 * Description for EVT_SOME_EVENT.
123 * @endEventTable
124 *
125 * @beginStyleTable
126 * @style{wxSOME_STYLE}:
127 * Description for wxSOME_STYLE.
128 * ...
129 * @endStyleTable
130 *
131 * @beginExtraStyleTable
132 * @style{wxSOME_EXTRA_STYLE}:
133 * Description for wxSOME_EXTRA_STYLE.
134 * ...
135 * @endExtraStyleTable
136 *
137 * @library{wxbase}
138 * @stdobjects
139 * ...here goes the list of predefined instances...
140 *
141 * @seealso
142 * ...here goes the see-also list...
143 * you can make references to topic overviews or other
144 * manual pages using the @ref command
145 */
146
147Note that the events, styles and extra-styles tables as
148well as @stdobjects and @seealso lists are optional.
149
150Also note that you shouldn't use the Doxygen builtin @sa command
151for the see-also list but rather the wxWidgets' alias @seealso
152in this case.
153
154
155Documentation comment for a function
156====================================
12646a5a 157
209f9b5e 158Start off with:
12646a5a 159
209f9b5e
FM
160/**
161 * ...here goes the description of the function....
162 *
163 * @param param1
164 * ...here goes the description for the first parameter of this function
165 * @param param2
166 * ...here goes the description for the second parameter of this function
167 * ...
168 *
169 * @return
170 * ...here goes the description of what the function returns...
171 *
172 * @note ...here go any eventual notes about this function...
173 *
174 * @remarks ...here go any eventual remarks about this function...
175 *
176 * @sa ...here goes the see-also list...
177 */
12646a5a 178
209f9b5e 179Note that the @return, @note, @remarks, @sa commands are optional.
12646a5a 180
209f9b5e
FM
181Also note that unlike for class' description, you should use the doxygen
182builtin @sa command here for see-also lists.
12646a5a 183
209f9b5e
FM
184The @param command has an optional attribute specifying the direction of
185the attribute. Possible values are "in" and "out". E.g.
12646a5a 186
209f9b5e
FM
187/**
188 * Copies bytes from a source memory area to a destination memory area,
189 * where both areas may not overlap.
190 * @param[out] dest The memory area to copy to.
191 * @param[in] src The memory area to copy from.
192 * @param[in] n The number of bytes to copy.
193 * @param[in,out] pmisc Used both as input and as output.
194 */
195void func(void *dest, const void *src, size_t n, void *pmisc);
12646a5a 196
12646a5a 197
209f9b5e
FM
198Documentation comment for a topic overview
199==========================================
12646a5a 200
209f9b5e
FM
201Topic overviews are stored inside the docs/doxygen/overviews folder
202and are completely placed inside a single comment block in the form of:
12646a5a 203
209f9b5e 204/*!
12646a5a 205
209f9b5e 206 @page overview_tname wxSomeStuff overview
12646a5a 207
209f9b5e
FM
208 This page provides an overview of the wxSomeStuff and related classes.
209 ....
12646a5a 210
209f9b5e
FM
211 @li @ref overview_tname_intro
212 @li @ref overview_tname_details
213 ...
12646a5a 214
209f9b5e 215 <hr>
12646a5a 216
12646a5a 217
209f9b5e 218 @section overview_tname_intro Introduction
12646a5a 219
209f9b5e 220 ...here goes the introduction to this topic...
12646a5a 221
12646a5a 222
209f9b5e 223 @section overview_tname_details Details
12646a5a 224
209f9b5e 225 ...here go the details to this topic...
12646a5a 226
209f9b5e 227*/
12646a5a 228
209f9b5e
FM
229Note that there is a convention in the anchor link names.
230Doxygen in fact requires that for each @page, @section, @subsection, etc tag,
231there is a corresponding link anchor.
12646a5a 232
209f9b5e 233The following conventions are used in wxWidgets doxygen comments:
12646a5a 234
209f9b5e
FM
2351) all "main" pages of the manual (those which are placed in docs/doxygen/mainpages)
236 have link anchors which begin with "page_"
12646a5a 237
209f9b5e
FM
2382) all topic overviews (those which are placed in docs/doxygen/overviews) have link
239 anchors which begin with "overview_"
408a83cb 240
209f9b5e
FM
2413) all @section, @subsection, @subsubsection tags should have as link anchor name
242 the name of the parent section plus a specific word separed with an underscore; e.g.:
408a83cb 243
209f9b5e 244/*!
408a83cb 245
209f9b5e 246 @page overview_tname wxSomeStuff overview
408a83cb 247
209f9b5e
FM
248 @section overview_tname_intro Introduction
249 @subsection overview_tname_intro_firstpart First part
250 @subsection overview_tname_intro_secondpart Second part
251 @subsubsection overview_tname_intro_secondpart_sub Second part subsection
252 @subsection overview_tname_intro_thirdpart Third part
408a83cb 253
209f9b5e
FM
254 @section overview_tname_details Details
255 ...
408a83cb 256
209f9b5e 257*/
408a83cb 258
408a83cb 259
209f9b5e 260=== EOF ===
f9364785 261
209f9b5e
FM
262Author: FM (under the lines of the previous technote about tex2rtf)
263Version: $Id$