added few DON'Ts
[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 - 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).
90
91 DON'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
97 - use non-alphanumeric characters in link anchors.
98
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
108
109 Documentation comment for a class
110 =================================
111
112 Start off with:
113
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
147 Note that the events, styles and extra-styles tables as
148 well as @stdobjects and @seealso lists are optional.
149
150 Also note that you shouldn't use the Doxygen builtin @sa command
151 for the see-also list but rather the wxWidgets' alias @seealso
152 in this case.
153
154
155 Documentation comment for a function
156 ====================================
157
158 Start off with:
159
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  */
178
179 Note that the @return, @note, @remarks, @sa commands are optional.
180
181 Also note that unlike for class' description, you should use the doxygen
182 builtin @sa command here for see-also lists.
183
184 The @param command has an optional attribute specifying the direction of 
185 the attribute. Possible values are "in" and "out". E.g.
186
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  */
195 void func(void *dest, const void *src, size_t n, void *pmisc);
196
197
198 Documentation comment for a topic overview
199 ==========================================
200
201 Topic overviews are stored inside the docs/doxygen/overviews folder
202 and are completely placed inside a single comment block in the form of:
203
204 /*!
205
206  @page overview_tname wxSomeStuff overview
207
208  This page provides an overview of the wxSomeStuff and related classes.
209  ....
210
211  @li @ref overview_tname_intro
212  @li @ref overview_tname_details
213  ...
214
215  <hr>
216
217
218  @section overview_tname_intro Introduction
219
220  ...here goes the introduction to this topic...
221
222
223  @section overview_tname_details Details
224
225  ...here go the details to this topic...
226
227 */
228
229 Note that there is a convention in the anchor link names.
230 Doxygen in fact requires that for each @page, @section, @subsection, etc tag, 
231 there is a corresponding link anchor.
232
233 The following conventions are used in wxWidgets doxygen comments:
234
235 1) all "main" pages of the manual (those which are placed in docs/doxygen/mainpages) 
236    have link anchors which begin with "page_"
237
238 2) all topic overviews (those which are placed in docs/doxygen/overviews) have link 
239    anchors which begin with "overview_"
240
241 3) 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.:
243
244 /*!
245
246  @page overview_tname wxSomeStuff overview
247
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
253
254  @section overview_tname_details Details
255  ...
256
257 */
258
259
260 === EOF ===
261
262 Author: FM (under the lines of the previous technote about tex2rtf)
263 Version: $Id$