fab3a1782024a9020b5fa8b982a70295812e02dd
[alexxy/gromacs.git] / doxygen / doxygen.md
1 Using Doxygen {#page_doxygen}
2 =============
3
4 This page documents how Doxygen is set up in the \Gromacs source tree,
5 as well as guidelines for adding new Doxygen comments.  Examples are included,
6 as well as tips and tricks for avoiding Doxygen warnings.  The guidelines focus
7 on C++ code and other new code that follows the new module layout.
8 Parts of the guidelines are still applicable to documenting older code (e.g.,
9 within `gmxlib/` or `mdlib/`), in particular the guidelines about formatting
10 the Doxygen comments and the use of \c \\internal.
11 \ref page_codelayout documents the overall structure of the documentation.
12
13 To get started quickly, you only need to read the first two sections to
14 understand the overall structure of the documentation, and take a look at the
15 examples at the end.  The remaining sections provide the details for
16 understanding why the examples are the way they are, and for more complex
17 situations.  They are meant more as a reference to look up solutions for
18 particular problems, rather than single-time reading.  To understand or find
19 individual Doxygen commands, you should first look at Doxygen documentation
20 (http://www.stack.nl/~dimitri/doxygen/manual/index.html).
21
22
23 Documentation flavors
24 =====================
25 The \Gromacs source tree is set up to produce three different levels of Doxygen
26 documentation:
27
28 1. Public API documentation (suffix `-user`), which documents functions and
29    classes exported from the library and intended for use outside the \Gromacs
30    library.
31 2. Library API documentation (suffix `-lib`), which additionally includes
32    functions and classes that are designed to be used from other parts of
33    \Gromacs, as well as some guidelines that are mostly of interest to
34    developers.
35 3. Full documentation (suffix `-full`), which includes (nearly) all (documented)
36    functions and classes in the source tree.
37
38 Each subsequent level of documentation includes all the documentation from the
39 levels above it.  The suffixes above refer to the suffixes of Doxygen input and
40 output files, as well as the name of the output directory.  When all the
41 flavors have been built, the front pages of the documentation contain links to
42 the other flavors, and explain the differences in more detail.
43
44 As a general guideline, the public API documentation should be kept free of
45 anything that a user linking against an unmodified \Gromacs does not see.
46 In other words, the public API documentation should mainly document the
47 contents of installed headers, and provide the necessary overview of using
48 those.  Also, verbosity requirements for the public API documentation are
49 higher: ideally, readers of the documentation could immediately start using the
50 API based on the documentation, without any need to look at the implementation.
51
52 Similarly, the library API documentation should not contain things that other
53 modules in \Gromacs can or should never call.  In particular, anything declared
54 locally in source files should be only available in the full documentation.
55 Also, if something is documented, and is not identified to be in the library
56 API, then it should not be necessary to call that function from outside its
57 module.
58
59
60 Building the documentation
61 ==========================
62
63 If you simply want to see up-to-date documentation, you can go to
64 http://jenkins.gromacs.org/job/Doxygen_Nightly_master/javadoc/html-lib/index.xhtml
65 to see the documentation for the current development version.
66 Jenkins also runs Doxygen for all changes pushed to Gerrit for master, and the
67 resulting documentation can be viewed from the link posted by Jenkins.  The
68 Doxygen build is marked as unstable if it introduces any Doxygen warnings.
69
70 You may need to build the documentation locally if you want to check the
71 results after adding/modifying a significant amount of comments.  This is
72 recommended in particular if you do not have much experience with Doxygen.
73 It is a good idea to build with all the different settings to see that the
74 result is what you want, and that you do not produce any warnings.
75 For local work, it is generally a good idea to set `GMX_COMPACT_DOXYGEN=ON`
76 CMake option, which removes some large generated graphs from the documentation
77 and speeds up the process significantly.
78
79 All files related to Doxygen reside in the `doxygen/` subdirectory in the source
80 and build trees.  In a freshly checked out source tree, this directory contains
81 various `Doxyfile-*.cmakein` files.  When you run CMake, corresponding files
82 `Doxyfile-user`, `Doxyfile-lib`, and `Doxyfile-full` are generated at the
83 corresponding location in the build tree.  There is also a
84 `Doxyfile-common.cmakein`, which is used to produce `Doxyfile-common`.
85 This file contains settings that are shared between all the input files.
86 `Doxyfile-compact` provides the extra settings for `GMX_COMPACT_DOXYGEN=ON`.
87
88 You can run Doxygen directly with one of the generated files (all output will
89 be produced under the current working directory), or build one of the
90 `doc-user`, `doc-lib`, and `doc-full` targets.  The targets run Doxygen in a
91 quieter mode and only show the warnings if there were any, and put the output
92 under `doxygen/` in the build tree.  The `doc-all` target builds all three
93 targets with less typing.
94
95 The generated documentation is put under `html-user/`, `html-lib/`, and/or
96 `html-full/` in the output directory.  Open `index.xhtml` file from one of
97 these subdirectories to start browsing (for \Gromacs developers, the
98 `html-lib/` is a reasonable starting point).  Log files with all Doxygen
99 warnings are also produced as `doxygen-*.log`, so you can inspect them after
100 the run.
101
102 You will need Doxygen 1.8.5 to build the current documentation.  Other versions
103 may work, but likely also produce warnings.  Additionally,
104 [graphviz](http://www.graphviz.org) and
105 [mscgen](http://www.mcternan.me.uk/mscgen/) are required for some graphs in
106 the documentation, and `latex` for formulas.  Working versions are likely
107 available through most package managers.  It is possible to build the
108 documentation without these tools, but you will see some errors and the related
109 figures will be missing from the documentation.
110
111
112 General guidelines for Doxygen markup
113 =====================================
114
115 Doxygen provides quite a few different alternative styles for documenting the
116 source code.  There are subtleties in how Doxygen treats the different types of
117 comments, and this also depends somewhat on the Doxygen configuration.  It is
118 possible to change the meaning of a comment by just changing the style of
119 comment it is enclosed in.  To avoid such issues, and to avoid needing to
120 manage all the alternatives, a single style throughout the source tree is
121 preferable.  When it comes to treatment of styles, \Gromacs uses the default
122 Doxygen configuration with one exception: `JAVADOC_AUTOBRIEF` is set ON to
123 allow more convenient one-line brief descriptions in C code.
124
125 Majority of existing comments in \Gromacs uses Qt-style comments (`/*!` and
126 `//!` instead of `/*``*` and `///`, \c \\brief instead of \c \@brief etc.),
127 so these should be used also for new documentation.  There is a single
128 exception for brief comments in C code; see below.
129
130 Similarly, existing comments use `/*!` for multiline comments in both C and
131 C++ code, instead of using multiple `//!` lines for C++.  The rationale is that
132 since the code will be a mixture of both languages for a long time, it is more
133 uniform to use similar style in both.  Also, since files will likely transition
134 from C to C++ gradually, rewriting the comments because of different style
135 issues should not generally be necessary.  Finally, multi-line `//!` comments
136 can work differently depending on Doxygen configuration, so it is better to
137 avoid that ambiguity.
138
139 When adding comments, ensure that a short brief description is always produced.
140 This is used in various listings, and should briefly explain the purpose of the
141 method without unnecessarily expanding those lists.
142 The basic guideline is to start all comment blocks with \c \\brief (possibly
143 after some other Doxygen commands).
144 If you want to avoid the \c \\brief for one-liners, you can use `//!`, but the
145 description must fit on a single line; otherwise, it is not interpreted as a
146 brief comment.  Note in particular that a simple `/*!` without a \c \\brief
147 does not produce a brief description.
148 Also note that \c \\brief marks the whole following paragraph as a brief
149 description, so you should insert an empty line after the intended brief
150 description.
151
152 In C code, `//` comments must be avoided because some compilers do not like
153 them.  If you want to avoid the \c \\brief for one-liners in C code, use
154 `/*``*` instead of `//!`.  If you do this, the brief description should not
155 contain unescaped periods except at the end.  Because of this, you should
156 prefer `//!` in C++ code.
157
158 Put the documentation comments in the header file that contains the
159 declaration, if such a header exists.
160 Implementation-specific comments that do not influence how a method
161 is used can go into the source file, just before the method definition, with an
162 \c \\internal tag in the beginning of the comment block.  Doxygen-style comments
163 within functions are not generally usable.
164
165 At times, you may need to exclude some part of a header or a source file such
166 that Doxygen does not see it at all.  In general, you should try to avoid this,
167 but it may be necessary to remove some functions that you do not want to appear
168 in the public API documentation, and which would generate warnings if left
169 undocumented, or to avoid Doxygen warnings from code it does not understand.
170 Prefer \c \\cond and \c \\endcond to do this.  If \c \\cond does not work for
171 you, you can also use \c \#ifndef `DOXYGEN`.  If you exclude a class method in
172 a header, you also need to exclude it in the source code to avoid warnings.
173
174
175 \Gromacs specifics
176 =================
177
178 The general guidelines on the style of Doxygen comments were given above.
179 This section introduces \Gromacs specific constructs currently used in Doxygen
180 documentation, as well as how \Gromacs uses Doxygen groups to organize the
181 documentation.
182
183 Controlling documentation visibility
184 ------------------------------------
185
186 To control in which level of documentation a certain function appears, three
187 different mechanisms are used:
188 * Global Doxygen configuration.  This is mainly used to include
189   declarations local to source files only in the full documentation.
190   You can find the details from the `Doxyfile-*.cmakein` files, and some of
191   them are also mentioned below on individual code constructs.
192 * The standard Doxygen command \c \\internal marks the documentation to be only
193   extracted into the full documentation (`INTERNAL_DOCS` is `ON` only for the
194   full documentation).  This should be used as a first command in a comment
195   block to exclude all the documentation.  It is possible to use \c \\internal
196   and \c \\endinternal to exclude individual paragraphs, but \c \\if `internal`
197   is preferred (see below).
198   In addition, \Gromacs-specific custom Doxygen command \c \\libinternal is
199   provided, which should be used the same way to exclude the documentation from
200   the public API documentation.  This command expands to either \c \\internal
201   or to a no-op, depending on the documentation level.
202 * Doxygen commands \c \\if and \c \\cond can be used with section names
203   `libapi` and `internal` to only include the documentation in library API and
204   the full documentation, respectively.  `libapi` is also defined in the full
205   documentation.  These are declared using `ENABLED_SECTIONS` in the Doxygen
206   configuration files.
207
208 Examples of locations where it is necessary to use these explicit commands are
209 given below in the sections on individual code constructs.
210
211 Modules as Doxygen groups
212 -------------------------
213
214 As described in \ref page_codelayout, each subdirectory under `src/gromacs/`
215 represents a _module_, i.e., a somewhat coherent collection of routines.
216 Doxygen cannot automatically generate a list of routines in a module; it only
217 extracts various alphabetical indexes that contain more or less all documented
218 functions and classes.  To help reading the documentation, the routines for a
219 module should be visible in one place.
220
221 \Gromacs uses Doxygen groups to achieve this: for each documented module, there
222 is a \c \\defgroup definition for the module, and all the relevant classes and
223 functions need to be manually added to this group using \c \\ingroup and
224 \c \\addtogroup.
225 The group page also provides a natural place for overview documentation about
226 the module, and can be navigated to directly from the "Modules" tab in the
227 generated documentation.
228
229 Some notes about using \c \\addtogroup are in order:
230 * \c \\addtogroup only adds the elements that it directly contains into the
231   group.  If it contains a namespace declaration, only the namespace is added
232   to the group, but none of the namespace contents are.  For this reason,
233   \c \\addtogroup should go within the innermost scope, around the members that
234   should actually be added.
235 * If the module should not appear in the public API documentation, its
236   definition (\c \\defgroup) should be prefixed with a \c \\libinternal.
237   In this case, also all \c \\addtogroup commands for this module should be
238   similarly prefixed.  Otherwise, they create the group in the public API
239   documentation, but without any of the content from the \c \\defgroup
240   definition.  This may also cause the contents of the \c \\addtogroup section
241   to appear in the public API documentation, even if it otherwise would not.
242
243 Public API and library API groups
244 ---------------------------------
245
246 In addition to the module groups, two fixed groups are provided:
247 `group_publicapi` and `group_libraryapi`.  Classes and files can be added to
248 these groups using \Gromacs specific custom \c \\inpublicapi and
249 \c \\inlibraryapi commands.  The generated group documentation pages are not
250 very useful, but annotated classes and files show the API definition under the
251 name, making this information more easily accessible.  These commands in
252 file-level comments are also used for some automatic intermodule dependency
253 validation (see below).
254
255 Note that functions, enumerations, and other entities that do not have a
256 separate page in the generated documentation can only belong to one group;
257 in such a case, the module group is preferred over the API group.
258
259 Automatic dependency checking
260 -----------------------------
261
262 The build system provides a `doc-check` target that automatically checks some
263 aspects of the documentation, as well as checking that header files are
264 actually used according to their API specifications (i.e., an internal headers
265 are not included from other modules).  The checks depend on correct usage of
266 the commands listed above, in particular the visibility and API definitions in
267 file-level comments.  These checks also provide some level of enforcement for
268 rules about dependencies between the modules, but currently the checks are not
269 run automatically.
270
271 The checker currently checks for a few different types of issues:
272 * For all Doxygen documentation (currently does not apply for members that do
273   not appear in the documentation):
274    * If a member has documentation, it should have a brief description.
275    * A note is issued for in-body documentation for functions, since this is
276      ignored by our current settings.
277    * If a class has documentation, it should have public documentation only if
278      it appears in an installed header.
279    * If a class and its containing file has documentation, the class
280      documentation should not be visible if the file documentation is not.
281 * For all files:
282    * Consistent usage of
283
284          #include "..." // This should be used for Gromacs headers
285
286      and
287
288          #include <...> // This should be used for system and external headers
289
290    * Installed headers must not include non-installed headers, and must include
291      all other \Gromacs headers using relative paths so that they resolve
292      correctly also when installed.
293 * For documented files:
294    * Installed headers should have public documentation, and other files should
295      not.
296    * The API level specified for a file should not be higher than where its
297      documentation is visible.  For example, only publicly documented headers
298      should be specified as part of the public API.
299    * If an \c \\ingroup module_foo exists, it should match the subdirectory
300      that the file is actually part of in the file system.
301    * If a \c \\defgroup module_foo exists for the subdirectory where the file is,
302      the file should contain \c \\ingroup module_foo.
303    * Files should not include other files whose documentation visibility is
304      lower (if the included file is not documented, the check is skipped).
305 * For files that are part of documented modules
306   (\c \\defgroup module_foo exists for the subdirectory):
307    * Such files should not be included from outside their module if they are
308      undocumented or are not specified as part of library or public API.
309 * For all modules:
310    * There should not be cyclic include dependencies between modules.
311
312 The checker is based on extracting the Doxygen documentation in XML format.
313 This information is then read using a Python script, and combined with
314 information extracted from the file system and knowledge about the \Gromacs
315 source tree layout.  The Python scripts are in the `doxygen/` folder.
316 In addition to printing the issues, they are also written into
317 `doxygen/doxygen-check.log` for later inspection.
318
319 The script is not currently perfect (either because of unfinished
320 implementation, or because Doxygen bugs or incompleteness of the Doxygen XML
321 output), and the current code also contains issues that the script detects, but
322 the authors have not fixed.  To allow the script to still be used,
323 `doxygen/suppressions.txt` contains a list of issues that are filtered out from
324 the report.  The syntax is simple:
325
326     <file>: <text>
327
328 where `<file>` is a path to the file that reports the message, and `<text>` is
329 the text reported.  Both support `*` as a wildcard.  If `<file>` is empty, the
330 suppression matches only messages that do not have an associated file.
331 `<file>` is matched against the trailing portion of the file name to make it
332 work even though the script reports absolute paths.
333 Empty lines and lines starting with `#` are ignored.
334
335 To add suppression for an issue, the line that reports the issue can be copied
336 into `suppressios.txt`, and the line number (if any) removed.  If the
337 issue does not have a file name (or a pseudo-file) associated, a leading `:`
338 must be added.  To cover many similar issues, parts of the line can then be
339 replaced with wildcards.
340
341 A separate suppression mechanism is in place for cyclic dependencies: to
342 suppress a cycle between moduleA and moduleB, add a line with format
343
344     moduleA -> moduleB
345
346 into `doxygen/cycle-suppressions.txt`.  This suppresses all cycles that contain
347 the mentioned edge.  Since a cycle contains multiple edges, the suppression
348 should be made for the edge that is determined to be an incorrect dependency.
349
350 For some false positives from the script, the suppression mechanism is the
351 easiest way to silence the script, but otherwise the goal would be to minimize
352 the number of suppressions.
353
354 As a side effect, the XML extraction makes Doxygen parse all comments in the
355 code, even if they do not appear in the documentation.  This can reveal latent
356 issues in the comments, like invalid Doxygen syntax.  The messages from the XML
357 parsing are stored in `doxygen/doxygen-xml.log` in the build tree, similar to
358 other Doxygen runs.
359
360 The `doc-check` target requires Python 2.7 (other versions may work, but have
361 not been tested).
362
363 Include dependency graphs
364 -------------------------
365
366 The build system also provides an `dep-graphs` target that generates include
367 dependency graphs with some additional annotations.
368 One graph is produced that shows all the modules under `src/gromacs/`, and
369 their include dependencies.  Additionally, a file-level graph is produced for
370 each module, showing the include dependencies within that module.  Currently,
371 these are mostly for eye candy, but they can also be used for analyzing
372 problematic dependencies to clean up the architecture.
373 The output is put in `doxygen/depgraphs/` in the build tree.
374
375 As with `doc-check`, Python 2.7 is required (other versions may work, but have
376 not been tested).  To get `.png` versions of the graphs, `graphviz` is
377 additionally required.
378
379 ### Module graph ###
380
381 The graph is written into `module-deps.dot.png`.
382
383 Node colors:
384 <dl>
385 <dt>gray background</dt>
386 <dd>undocumented module</dd>
387 <dt>orange background</dt>
388 <dd>documented utility modules</dd>
389 <dt>red background</dt>
390 <dd>documented analysis modules</dd>
391 <dt>violet background</dt>
392 <dd>documented MD execution modules</dd>
393 <dt>light blue border</dt>
394 <dd>module contains public API (installed) headers</dd>
395 </dl>
396
397 Edge colors (an edge with a certain color indicates that types above it in the
398 list are not present):
399 <dl>
400 <dt>red</dt>
401 <dd>invalid dependency</dd>
402 <dt>gray</dt>
403 <dd>legacy dependency
404 (dependency on undocumented file, or to undocumented directories)</dd>
405 <dt>solid black</dt>
406 <dd>public header depends on the other module</dd>
407 <dt>solid blue</dt>
408 <dd>library header depends on the other module</dd>
409 <dt>dashed blue</dt>
410 <dd>source file depends on library header in the other module</dd>
411 <dt>dashed black</dt>
412 <dd>source file depends on public header in the other module</dd>
413 <dt>dashed green</dt>
414 <dd>test file depends on the other module</dd>
415 </dl>
416
417 ### File graph ###
418
419 The graphs are written to <em>module_name</em>`-deps.dot.png`.
420
421 Node colors:
422 <dl>
423 <dt>light blue</dt>
424 <dd>public API (installed) headers</dd>
425 <dt>dark blue</dt>
426 <dd>library API headers</dd>
427 <dt>gray</dt>
428 <dd>source files</dd>
429 <dt>light green</dt>
430 <dd>test files</dd>
431 <dt>white</dt>
432 <dd>other files</dd>
433 </dl>
434
435 Each edge signifies an include dependency; there is no additional information
436 currently included.
437
438 Documenting specific code constructs
439 ====================================
440
441 This section describes the techical details and some tips and tricks for
442 documenting specific code constructs such that useful documentation is
443 produced.  If you are wondering where to document a certain piece of
444 information, see the documentation structure section on \ref page_codelayout.
445 The focus of the documentation should be on the overview content: Doxygen pages
446 and the module documentation.  An experienced developer can relatively easily
447 read and understand individual functions, but the documentation should help
448 in getting the big picture.
449
450 Doxygen pages
451 -------------
452
453 The pages that are accessible through navigation from the front page are
454 written using Markdown and are located under `doxygen/`.  Each page should be
455 placed in the page hierarchy by making it a subpage of another page, i.e., it
456 should be referenced once using \c \\subpage.  `mainpage.md` is the root of the
457 hierarchy.
458
459 If you need to exclude a page from the public API docs, you need to add it to
460 an exclude list in `Doxyfile-user.cmakein`, and ensure that there are no
461 references to the page from public API documentation.  \c \\if `libapi` can be
462 used to add references in content that is otherwise public.
463 Generally, the pages should be on a high enough level and provide overview
464 content that is useful enough such that it is not necessary to exclude them
465 from the library API documentation.
466
467 Modules
468 -------
469
470 For each module, decide on a header file that is the most important one for
471 that module (if there is no self-evident header, it may be better to designate,
472 e.g., module-doc.h for this purpose, but this is currently not done for any
473 module).  This header should contain the \c \\defgroup definition for the
474 module.  The name of the group should be `module_`<em>name</em>, where _name_
475 is the name of the subdirectory that hosts the module.
476
477 The module should be added to an appropriate group (see `doxygen/misc.cpp` for
478 definitions) using \c \\ingroup to organize the "Modules" tab in the generated
479 documentation.
480
481 One or more contact persons who know about the contents of the module should be
482 listed using \c \\author commands.  This provides a point of contact if one
483 has questions.
484
485 Classes/structs
486 ---------------
487
488 Classes and structs in header files appear always in Doxygen documentation,
489 even if their enclosing file is not documented.  So start the documentation
490 blocks of classes that are not part of the public API with \c \\internal or
491 \c \\libinternal.  Classes declared locally in source files or in unnamed
492 namespaces only appear in the full documentation.
493
494 If a whole class is not documented, this does not currently generate any
495 warning.  The class is simply exluded from the documentation.  But if a member
496 of a documented class is not documented, a warning is generated.  Guidelines for
497 documenting free functions apply to methods of a class as well.
498
499 For base classes, the API classification (\c \\inpublicapi or
500 \c \\inlibraryapi) should be based on where the class is meant to be
501 subclassed.  The visibility (\c \\internal or \c \\libinternal), in contrast,
502 should reflect the API classification of derived classes such that the base
503 class documentation is always generated together with the derived classes.
504
505 For classes that are meant to be subclassed and have protected members, the
506 protected members should only appear at the documentation level where the class
507 is meant to be subclassed.  For example, if a class is meant to be subclassed
508 only within a module, the protected members should only appear in the
509 full documentation.  This can be accomplished using \c \\cond (note that you
510 will need to add the \c \\cond command also to the source files to hide the
511 same methods from Doxygen, otherwise you will get confusing warnings).
512
513 Methods/functions/enums/macros
514 ------------------------------
515
516 These items do not appear in the documentation unless their enclosing scope is
517 documented.  For class members, the scope is the class; otherwise, it is the
518 namespace if one exists, or the file.  An \c \\addtogroup can also define a
519 scope if the group has higher visibility than the scope outside it.
520 So if a function is not within a namespace (mostly applicable to C code) and
521 has the same visibility as its enclosing file, it is not necessary to add a
522 \c \\internal or \c \\libinternal.
523
524 Static functions are currently extracted for all documentation flavors to allow
525 headers to declare `static inline` functions (used in, for example, math code).
526 Functions in anonymous namespaces are only extracted into the full
527 documentation.  Together with the above rules, this means that you should avoid
528 putting a `static` function within a documented namespace, even within source
529 files, or it may inadvertently appear in the public API documentation.
530
531 If you want to exclude an item from the documentation, you need to put in
532 inside a \c \\cond block such that Doxygen does not see it.
533 Otherwise, a warning for an undocumented function is generated.  You need to
534 enclose both the declaration and the definition with \c \\cond.
535
536 Files
537 -----
538
539 Each documented file should start with a documentation block (right after the
540 copyright notice) that documents the file.  See the examples section for exact
541 formatting.  Things to note:
542 * Please do not specify the file name explicitly after \c \\file.  By default,
543   a file comment applies to the file it is contained in, and an explicit file
544   name only adds one more thing that can get out of date.
545 * \c \\brief cannot appear on the same line as the \c \\file, but should be on
546   the next line.
547 * \c \\internal or \c \\libinternal should indicate where the header is visible.
548   As a general guideline, all installed headers should appear in the public API
549   documentation, i.e., not contain these commands.  If nothing else, then to
550   document that it does not contain any public API functions.  Headers that
551   declare anything in the library API should be marked with \c \\libinternal,
552   and the rest with \c \\internal.
553 * All source files, as well as most test files, should be documented with
554   \c \\internal, since they do not provide anything to public or library API,
555   and this avoids unintentionally extracting things from the file into those
556   documentations.  Shared test files used in tests from other modules should be
557   marked with \c \\libinternal.
558 * \c \\inpublicapi or \c \\inlibraryapi should be used to indicate where the
559   header is meant to be directly included.
560 * As with files, one or more contact persons should be listed with \c \\author.
561   If you make significant modifications or additions to a file, consider adding
562   an \c \\author line for yourself.
563
564 Directories
565 -----------
566
567 Directory documentation does not typically contain useful information beyond a
568 possible brief description, since they correspond very closely to modules, and
569 the modules themselves are documented.  A brief description is still useful to
570 provide a high-level overview of the source tree on the generated "Files" page.
571 A reference to the module is typically sufficient as a brief description for a
572 directory.  All directories are currently documented in
573 `doxygen/directories.cpp`.
574
575
576 Examples
577 ========
578
579 Basic C++
580 ---------
581
582 Here is an example of documenting a C++ class and its containing header file.
583 Comments in the code and the actual documentation explain the used Doxygen
584 constructs.
585
586 \includelineno doxygen-example.cpp
587
588 Basic C
589 -------
590
591 Here is another example of documenting a C header file (so avoiding all
592 C++-style comments), and including free functions.  It also demonstrates the use
593 of \c \\addtogroup to add multiple functions into a module group without repeated
594 \c \\ingroup tags.
595
596 \includelineno doxygen-example.c
597
598 Scoping and visibility rules
599 ----------------------------
600
601 The rules where Doxygen expects something to be documented, and when are
602 commands like \c \\internal needed, can be complex.  The examples below
603 describe some of the pitfalls.
604
605 \includelineno doxygen-example-scoping.cpp
606
607 Module documentation
608 --------------------
609
610 Documenting a new module should place a comment like this in a central header
611 for the module, such that the "Modules" tab in the generated documentation can
612 be used to navigate to the module.
613
614 \includelineno doxygen-example-module.cpp
615
616 Common mistakes
617 ---------------
618
619 The most common mistake, in particular in C code, is to forget to document the
620 file.  This causes Doxygen to ignore most comments in the file, so it
621 does not validate the contents of the comments either, nor is it possible to
622 actually check how the generated documentation looks like.
623
624 The following example shows some other common mistakes (and some less common)
625 that do not produce correct documentation, as well as Doxygen "features"/bugs
626 that can be confusing.
627 The issues are explained in normal comments above each code fragment.
628
629 \includelineno doxygen-example-issues.cpp
630
631 Existing code
632 -------------
633
634 More examples you can find by looking at existing code in the source tree.  In
635 particular new C++ code such as that in the `src/gromacs/analysisdata/` and
636 `src/gromacs/options/` subdirectories contains a large amount of code
637 documented mostly along these guidelines.  Some comments in
638 `src/gromacs/selection/` (in particular, any C-like code) predate the
639 introduction of these guidelines, so those are not the best examples.