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