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