tn0003.txt 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  1. Adding wxWidgets class documentation
  2. ====================================
  3. This note is aimed at people wishing to add documentation for a
  4. class to either the main wxWidgets manual, or to their own
  5. manual.
  6. wxWidgets uses Doxygen to process header input files with embedded
  7. documentation in the form of C++ comments and output in HTML, and XML
  8. (Doxygen itself can also output Latex, manpages, RTF, PDF etc).
  9. See http://www.doxygen.org for more info about Doxygen.
  10. If you want to add documentation of a new class/function to the
  11. existing manual in docs/doxygen, you need to create a new .h file,
  12. e.g. myclass.h, under the interface folder, which contains the public
  13. interface of the new class/function in C++ syntax.
  14. The documentation can then be added in form of Doxygen comments to
  15. the header file.
  16. You may also want to write a separate topic file,
  17. e.g. docs/doxygen/overviews/myclass.h, and add the entry to
  18. docs/doxygen/mainpages/topics.h.
  19. If applicable, also add an entry to one of the docs/doxygen/mainpages/cat_*.h
  20. files.
  21. You can generate a first raw version of myclass.h simply taking its
  22. "real" header and removing all the private and protected sections and
  23. in general removing everything the user "shouldn't know": i.e. all things
  24. which are implementation details.
  25. Running Doxygen
  26. ===============
  27. First, make sure you have a recent version of Doxygen installed in your system
  28. (you'll need Doxygen >= 1.5.7).
  29. On Unix:
  30. 1) run wxWidgets/docs/doxygen/regen.sh [format-to-generate]
  31. On Windows:
  32. 1) cd wxWidgets/docs/doxygen
  33. 2) run regen.bat [format-to-generate]
  34. If you don't specify which format to [re]generate, all output formats will
  35. be enabled. Possible values for [format-to-generate] are: "html", "chm", "latex",
  36. "xml" and "all".
  37. The output of Doxygen is all placed in the wxWidgets/docs/doxygen/out folder.
  38. Important Dos and Don'ts
  39. ========================
  40. DO:
  41. - Doxygen supports both commands in the form \command and @command;
  42. all wxWidgets documentation uses the @command form.
  43. Follow strictly this rule.
  44. - strive to use dedicated Doxygen commands for e.g. notes, lists,
  45. sections, etc. The "Special commands" page:
  46. http://www.stack.nl/~dimitri/doxygen/commands.html
  47. is your friend!
  48. It's also very important to make a consistent use of the ALIASES
  49. defined by wxWidgets' Doxyfile. Open that file for more info.
  50. - when you write true, false and NULL with their C++ semantic meaning,
  51. then use the @true, @false and @NULL commands.
  52. - separate different paragraphs with an empty comment line.
  53. This is important otherwise Doxygen puts everything in the same
  54. paragraph making the result less readable.
  55. - leave a blank comment line between a @section, @subsection, @page
  56. and the next paragraph.
  57. - test your changes, both reading the generated HTML docs and by looking
  58. at the "doxygen.log" file produced (which will warn you about any
  59. eventual mistake found in the comments).
  60. - quote all the following characters prefixing them with a "@" char:
  61. @ $ \ & < > # %
  62. unless they appear inside a @code or @verbatim section
  63. (you can also use HTML-style escaping, e.g. &amp; rather than @ escaping)
  64. - when using a Doxygen alias like @itemdef{}, you need to escape the
  65. comma characters which appear on the first argument, otherwise Doxygen
  66. will interpret them as the marker of the end of the first argument and
  67. the beginning of the second argument's text.
  68. E.g. if you want to define the item "wxEVT_MACRO(id, func)" you need to
  69. write:
  70. @itemdef{wxEVT_MACRO(id\, func), This is the description of the macro}
  71. Also note that you need to escape only the commas of the first argument's
  72. text; second argument can have up to 10 commas unescaped (see the Doxyfile
  73. for the trick used to implement this).
  74. - for linking use one of:
  75. => the @ref command to refer to topic overviews;
  76. => the () suffix to refer to function members of the same class you're
  77. documenting or to refer to global functions or macros;
  78. => the classname:: operator to refer to functions of classes different
  79. from the one you're documenting;
  80. => the :: prefix to refer to global variables (e.g. ::wxEmptyString).
  81. Class names are auto-linked by Doxygen without the need of any explicit
  82. command.
  83. DON'T:
  84. - use jargon, such as 'gonna', or omit the definite article.
  85. The manual is intended to be a fluent, English document and
  86. not a collection of rough notes.
  87. - use non-alphanumeric characters in link anchors.
  88. - use Doxygen @b @c @e commands when referring to more than a single word;
  89. in that case you need to use the <b>...</b>, <tt>...</tt>, <em>...</em>
  90. HTML-style tags instead
  91. - use HTML style tags for creation of tables or lists.
  92. Use wx aliases instead like @beginTable, @row2col, @row3col, @endTable and
  93. @beginDefList, @itemdef, @endDefList, etc.
  94. See the Doxyfile.inc for more info.
  95. Documentation comment for a class
  96. =================================
  97. Start off with:
  98. /**
  99. @class wxMyClass
  100. ...here goes the description...
  101. @beginEventTable
  102. @event{EVT_SOME_EVENT(id, func)}:
  103. Description for EVT_SOME_EVENT.
  104. @endEventTable
  105. @beginStyleTable
  106. @style{wxSOME_STYLE}:
  107. Description for wxSOME_STYLE.
  108. ...
  109. @endStyleTable
  110. @beginExtraStyleTable
  111. @style{wxSOME_EXTRA_STYLE}:
  112. Description for wxSOME_EXTRA_STYLE.
  113. ...
  114. @endExtraStyleTable
  115. @library{wxbase}
  116. @category{cat_shortcut}
  117. @nativeimpl{wxgtk, wxmsw, ...}
  118. @onlyfor{wxgtk, wxmsw, ...}
  119. @appearance{button.png}
  120. @stdobjects
  121. ...here goes the list of predefined instances...
  122. @see ...here goes the see-also list...
  123. you can make references to topic overviews or other
  124. manual pages using the @ref command
  125. */
  126. Note that everything *except* the @class, @library and @category
  127. commands are optionals.
  128. Also note that if you use @section and @subsection in the class description
  129. (at the beginning), you should use as the section's anchor name "xxxx_yyyy"
  130. where "xxxx" is the class name without the initial "wx" in lowercase
  131. and "yyyy" is a lowercase word which uniquely identifies that section.
  132. E.g.:
  133. /**
  134. @class wxMyClass
  135. This class does not exist really and is only used as an example
  136. of best documentation practices.
  137. @section myclass_special Special functions of this class
  138. This section describes the functions whose usage is reserved for
  139. wxWidgets internal mechanisms... etc etc...
  140. @section myclass_custom Customizing wxMyClass
  141. What if you want to customize this powerful class?
  142. First you should do this and that, etc etc...
  143. @library{wxbase}
  144. @category{misc}
  145. @see wxMyOtherClass
  146. */
  147. Documentation comment for a function
  148. ====================================
  149. Start off with:
  150. /**
  151. ...here goes the description of the function....
  152. @param param1
  153. ...here goes the description for the first parameter of this function
  154. @param param2
  155. ...here goes the description for the second parameter of this function
  156. ...
  157. @return
  158. ...here goes the description of what the function returns...
  159. @note ...here go any eventual notes about this function...
  160. @remarks ...here go any eventual remarks about this function...
  161. @see ...here goes the see-also list...
  162. */
  163. Note that the @return, @note, @remarks, @see commands are optional.
  164. The @param command has an optional attribute specifying the direction of
  165. the attribute. Possible values are "in" and "out". E.g.
  166. /**
  167. * Copies bytes from a source memory area to a destination memory area,
  168. * where both areas may not overlap.
  169. * @param[out] dest The memory area to copy to.
  170. * @param[in] src The memory area to copy from.
  171. * @param[in] n The number of bytes to copy.
  172. * @param[in,out] pmisc Used both as input and as output.
  173. */
  174. void func(void *dest, const void *src, size_t n, void *pmisc);
  175. Documentation comment for a topic overview
  176. ==========================================
  177. Topic overviews are stored inside the docs/doxygen/overviews folder
  178. and are completely placed inside a single comment block in the form of:
  179. /*!
  180. @page overview_tname wxSomeStuff overview
  181. This page provides an overview of the wxSomeStuff and related classes.
  182. ....
  183. @li @ref overview_tname_intro
  184. @li @ref overview_tname_details
  185. ...
  186. <hr>
  187. @section overview_tname_intro Introduction
  188. ...here goes the introduction to this topic...
  189. @section overview_tname_details Details
  190. ...here go the details to this topic...
  191. */
  192. Note that there is a convention in the anchor link names.
  193. Doxygen in fact requires that for each @page, @section, @subsection, etc tag,
  194. there is a corresponding link anchor.
  195. The following conventions are used in wxWidgets doxygen comments:
  196. 1) all "main" pages of the manual (those which are placed in
  197. docs/doxygen/mainpages) have link anchors which begin with "page_"
  198. 2) all topic overviews (those which are placed in docs/doxygen/overviews) have
  199. link anchors which begin with "overview_"
  200. 3) all @section, @subsection, @subsubsection tags should have as link anchor
  201. name the name of the parent section plus a specific word separated with an
  202. underscore; e.g.:
  203. /*!
  204. @page overview_tname wxSomeStuff overview
  205. @section overview_tname_intro Introduction
  206. @subsection overview_tname_intro_firstpart First part
  207. @subsection overview_tname_intro_secondpart Second part
  208. @subsubsection overview_tname_intro_secondpart_sub Second part subsection
  209. @subsection overview_tname_intro_thirdpart Third part
  210. @section overview_tname_details Details
  211. ...
  212. */
  213. === EOF ===
  214. Author: FM (along the lines of the previous technote about tex2rtf)