]>
Commit | Line | Data |
---|---|---|
fc2171bd | 1 | Adding wxWidgets class documentation |
12646a5a JS |
2 | ==================================== |
3 | ||
4 | This note is aimed at people wishing to add documentation for a | |
fc2171bd | 5 | class to either the main wxWidgets manual, or to their own |
12646a5a JS |
6 | manual. |
7 | ||
209f9b5e FM |
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. | |
12646a5a | 12 | |
209f9b5e FM |
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. | |
12646a5a | 19 | |
209f9b5e FM |
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. | |
12646a5a | 23 | |
209f9b5e | 24 | If applicable, also add an entry to docs/doxygen/mainpages/categories.h. |
12646a5a | 25 | |
209f9b5e FM |
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. | |
12646a5a | 30 | |
12646a5a | 31 | |
209f9b5e FM |
32 | Running Doxygen |
33 | =============== | |
12646a5a | 34 | |
209f9b5e | 35 | First, make sure you have a recent version of Doxygen installed in your system. |
3ca6a5f0 | 36 | |
209f9b5e | 37 | For 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 | |
45 | Important Dos and Don'ts | |
46 | ======================== | |
47 | ||
48 | DO: | |
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 | |
a51ea7f1 FM |
78 | unless they appear inside a @code or @verbatim section. |
79 | ||
209f9b5e FM |
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). | |
b74d0665 | 92 | |
12646a5a JS |
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 | ||
209f9b5e | 99 | - use non-alphanumeric characters in link anchors. |
12646a5a | 100 | |
c03100c3 FM |
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 | ||
12646a5a | 110 | |
209f9b5e FM |
111 | Documentation comment for a class |
112 | ================================= | |
12646a5a JS |
113 | |
114 | Start off with: | |
115 | ||
209f9b5e FM |
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 | ==================================== | |
12646a5a | 159 | |
209f9b5e | 160 | Start off with: |
12646a5a | 161 | |
209f9b5e FM |
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 | */ | |
12646a5a | 180 | |
209f9b5e | 181 | Note that the @return, @note, @remarks, @sa commands are optional. |
12646a5a | 182 | |
209f9b5e FM |
183 | Also note that unlike for class' description, you should use the doxygen |
184 | builtin @sa command here for see-also lists. | |
12646a5a | 185 | |
209f9b5e FM |
186 | The @param command has an optional attribute specifying the direction of |
187 | the attribute. Possible values are "in" and "out". E.g. | |
12646a5a | 188 | |
209f9b5e FM |
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); | |
12646a5a | 198 | |
12646a5a | 199 | |
209f9b5e FM |
200 | Documentation comment for a topic overview |
201 | ========================================== | |
12646a5a | 202 | |
209f9b5e FM |
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: | |
12646a5a | 205 | |
209f9b5e | 206 | /*! |
12646a5a | 207 | |
209f9b5e | 208 | @page overview_tname wxSomeStuff overview |
12646a5a | 209 | |
209f9b5e FM |
210 | This page provides an overview of the wxSomeStuff and related classes. |
211 | .... | |
12646a5a | 212 | |
209f9b5e FM |
213 | @li @ref overview_tname_intro |
214 | @li @ref overview_tname_details | |
215 | ... | |
12646a5a | 216 | |
209f9b5e | 217 | <hr> |
12646a5a | 218 | |
12646a5a | 219 | |
209f9b5e | 220 | @section overview_tname_intro Introduction |
12646a5a | 221 | |
209f9b5e | 222 | ...here goes the introduction to this topic... |
12646a5a | 223 | |
12646a5a | 224 | |
209f9b5e | 225 | @section overview_tname_details Details |
12646a5a | 226 | |
209f9b5e | 227 | ...here go the details to this topic... |
12646a5a | 228 | |
209f9b5e | 229 | */ |
12646a5a | 230 | |
209f9b5e FM |
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. | |
12646a5a | 234 | |
209f9b5e | 235 | The following conventions are used in wxWidgets doxygen comments: |
12646a5a | 236 | |
209f9b5e FM |
237 | 1) all "main" pages of the manual (those which are placed in docs/doxygen/mainpages) |
238 | have link anchors which begin with "page_" | |
12646a5a | 239 | |
209f9b5e FM |
240 | 2) all topic overviews (those which are placed in docs/doxygen/overviews) have link |
241 | anchors which begin with "overview_" | |
408a83cb | 242 | |
209f9b5e FM |
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.: | |
408a83cb | 245 | |
209f9b5e | 246 | /*! |
408a83cb | 247 | |
209f9b5e | 248 | @page overview_tname wxSomeStuff overview |
408a83cb | 249 | |
209f9b5e FM |
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 | |
408a83cb | 255 | |
209f9b5e FM |
256 | @section overview_tname_details Details |
257 | ... | |
408a83cb | 258 | |
209f9b5e | 259 | */ |
408a83cb | 260 | |
408a83cb | 261 | |
209f9b5e | 262 | === EOF === |
f9364785 | 263 | |
209f9b5e FM |
264 | Author: FM (under the lines of the previous technote about tex2rtf) |
265 | Version: $Id$ |