Skip to content

Commit d01f569

Browse files
committed
Update documentation on doxygen
1 parent 94d307e commit d01f569

File tree

1 file changed

+42
-121
lines changed

1 file changed

+42
-121
lines changed

doc/documentation/doxygen.rst

Lines changed: 42 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -12,67 +12,56 @@ What is Doxygen and why does |FOURC| rely on it?
1212

1313
Doxygen is a documentation generator, i.e. a tool for writing software reference documentation.
1414
The documentation is written within the code, so documentation lives close by to the code that it is documenting.
15-
This makes it relatively easy to keep up to date.
15+
This makes it relatively easy to keep up-to-date.
1616
Doxygen can cross reference documentation and code, so that the reader of a document can easily refer to the actual code.
1717

18+
In contrast to the high-level documentation you are currently reading, Doxygen generates the more technical
19+
documentation of the code's API and relevant internals.
20+
1821
|FOURC|'s Policy
1922
~~~~~~~~~~~~~~~~
2023

21-
|FOURC| requires a set of minimum Doxygen items for each code entity.
22-
23-
At a bare minimum, |FOURC| requires that
24-
25-
- any source code file has a file header consisting of the tags
26-
- ``@file``
27-
- ``@brief``
28-
- ``@level``
29-
- any newly added source code entity has a ``@brief`` description, and functions additionally require at least the ``@param`` and ``@return`` information.
24+
|FOURC| requires Doxygen documentation for all new code.
3025

3126
It is the responsibility of the developer adding the new code to include the relevant documentation.
32-
It is the responsibility of the merge request reviewer to not allow a request to be merged
33-
until this minimum documentation is in place and is understandable to someone other than the author.
27+
During code review, reviewers need to check that documentation is present and understandable.
3428

3529
It is also highly recommended and encouraged that any time you come across undocumented entities,
36-
you either add the documentation yourself if you are knowledgeable enough to do so,
37-
or contact the file author and ask them to add the documentation.
30+
you take the time to document them. When you struggled to understand a piece of code,
31+
you can be sure that the next developer will struggle too, so it can be a great opportunity to improve the code base.
32+
Pull requests that "only" improve documentation of existing code are a welcome contribution!
3833
Our goal is to have a fully documented code base, and the more proactive every developer is about that, the easier it will be to achieve.
3934

40-
> **Note:** Your IDE might offer supportive capabilities to ease Doxygen-style documentation.
41-
Checkout the :ref:`IDE setup instructions <Set-up-your-ide>` for details.
42-
4335
Building the Doxygen Documentation
4436
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4537

4638
Local build using CMake
4739
"""""""""""""""""""""""""""
4840

49-
|FOURC| has defined a custom build target ``documentation`` (see also our :ref:`list of custom build targets <build4Cwithcustomtargets>`.
41+
|FOURC| has defined a custom build target ``doxygen`` (see also our :ref:`list of custom build targets <build4Cwithcustomtargets>`.
5042
In order to create the Doxygen HTML webpage locally, just issue the command
5143

5244
::
5345

5446
cd <buildDirectory>
55-
make documentation
47+
ninja doxygen
5648

5749

58-
This will build the Doxygen documentation in the directory ``<buildDirectory>/doc/html/``.
59-
It can be viewed by accessing ``<buildDirectory>/doc/html/index.html`` in any browser.
50+
This will build the Doxygen documentation in the directory ``<buildDirectory>/doc/doxygen/html/``.
51+
It can be viewed by accessing ``<buildDirectory>/doc/doxygen/html/index.html`` in any browser.
6052

61-
To trigger a *re-build* of the documentation, just call ``make documentation`` again.
62-
The documentation target is always considered out of date and therefore always built.
63-
It is unfortunately not possible to only rebuild the documentation for changed code.
64-
However, Doxygen builds seem to benefit from using :ref:`ccache <ccache>`.
6553

6654
Pipeline build
6755
""""""""""""""""
6856

69-
We have a Doxygen pipeline in place that creates the Doxygen documentation every night.
70-
We check for errors in Latex processing. Other than that, no checks are performed right now.
57+
The Doxygen documentation is also built when you submit a pull request. A merge to the main branch
58+
will trigger the most recent version of the documentation to be built and published
59+
`here <https://4c-multiphysics.github.io/4C/doxygen/index.html>`_
7160

7261
General Remarks on documenting the code
7362
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7463

75-
Documenting source code already starts when writing the code (even before writing its comments and documentation).
64+
Documenting source code already starts when writing the code (even before writing comments and documentation).
7665
Here are some general remarks and guidelines taken from Robert C. Martin's book
7766
"Clean Code" to facilitate writing easy-to-understand and well-documented code [Martin08]_.
7867

@@ -96,32 +85,6 @@ Using pronouncable names makes it easier to discuss code with fellow users and d
9685
Don't be afraid of using non-abbreviated names!
9786
Typing on a keyboard is quick, and we use a code formatter to take care of formatting and line breaks.
9887

99-
Documenting a File
100-
~~~~~~~~~~~~~~~~~~~
101-
102-
Each source code file has to start with a file header that exhibits these tags:
103-
104-
- ``@file``: keyword to tell Doxygen, that this comment block is related to the file description.
105-
The file name **must not** to be given.
106-
- ``@brief``: summarize the file's content in a brief description
107-
108-
Here's an example:
109-
110-
.. code-block:: cpp
111-
112-
/*---------------------------------------------------------------------*/
113-
/*! @file
114-
@brief This header provides the interface for all FE simulations
115-
116-
@level 3
117-
*/
118-
/*---------------------------------------------------------------------*/
119-
120-
**Important:** Do not add personal contact information (like email, phone number, webpage)
121-
since they become outdated very quickly and make it more difficult to update maintainer information in the future.
122-
123-
If GitHooks have been configured properly, the ``pre-commit`` hook will enforce this policy and provide hints on how to fix policy violations.
124-
Furthermore, this policy is checked during the code checks in every pipeline run.
12588

12689
Documenting a Class or Struct
12790
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -163,7 +126,7 @@ Classes should be preceded by a comment block along these lines:
163126
public BaseClass<stuff>
164127
{
165128
// Insert class definition here.
166-
} // end of class ClassName
129+
}
167130
168131
Methods
169132
""""""""""
@@ -209,8 +172,8 @@ Within the class definition, methods should be preceded by a comment block along
209172
* @returns This is a description of what the function returns on completion,
210173
* if anything.
211174
*/
212-
returnType
213-
functionName(someType arg1, anotherType arg2, yetAnotherType arg3 = someDefaultValue);
175+
ReturnType
176+
function_name(Type1 arg1, Type2 arg2, Type3 arg3 = some_default_value);
214177
215178
216179
If any of the lines in the comment block above (``\note``, ``\warning``, ``\remark`, ``@pre``, ``@post``, ``@param``, ``\throws``, ``@returns``)
@@ -253,47 +216,36 @@ When documenting an ``enum``, use something along the lines of the following:
253216
*/
254217
enum EnumName
255218
{
256-
/*!< This is a description of the SOMETHING value of the enum.
257-
It can be as detailed as you like. */
258-
SOMETHING,
259-
SOMETHING_ELSE //!< This is a brief description of SOMETHING_ELSE.
219+
/**
220+
* This is a description of the something value of the enum.
221+
* It can be as detailed as you like.
222+
*/
223+
something,
224+
225+
/**
226+
* Description of another value of the enum.
227+
*/
228+
something_else,
260229
}; // end of enum EnumName
261230
262231
Typedefs and Usings
263232
""""""""""""""""""""""
264233

265-
When documenting a ``typedef``, the syntax is essentially the same as that used for member data:
234+
When documenting a ``using`` declaratin, the syntax is essentially the same as that used for member data:
266235

267236
.. code-block:: cpp
268237
269238
/*!
270-
* @brief A brief description of the typedef goes here. The brief
239+
* @brief A brief description of the using declaration goes here. The brief
271240
* description is terminated by a blank line.
272241
*
273-
* The detailed description of the typedef follows the blank line. If the
242+
* The detailed description of the using declaration follows the blank line. If the
274243
* brief description gives enough information to understand the typedef, its
275244
* use and purpose, then a detailed description may not be necessary.
276245
*/
277-
typedef OriginalType NewName;
278-
279-
However, as of C++11, we should really be phasing out ``typedef``s in favor of ``using`` statements.
280-
Unfortunately, Doxygen has not been updated to support those out of the box, so it needs a little help.
281-
We can use the ``\var`` command to tell Doxygen to document a ``using`` statement as if it were a variable:
282-
283-
.. code-block:: cpp
284-
285-
/*!
286-
* \var NewName
287-
*
288-
* @brief A brief description of the using statement goes here. The brief
289-
* description is terminated by a blank line.
290-
*
291-
* The detailed description of the using statement follows the blank line.
292-
* If the brief description gives enough information to understand the
293-
* using statement, then a detailed description may not be necessary.
294-
*/
295246
using NewName = OriginalType;
296247
248+
297249
Grouping Entities
298250
""""""""""""""""""""""
299251

@@ -396,35 +348,6 @@ the generated HTML will be such that it'll look like you copied and pasted the c
396348

397349
**Note:** If you do not wish all members of a group to share the same documentation, *each and every member must be documented separately*.
398350

399-
Documenting a Namespace
400-
~~~~~~~~~~~~~~~~~~~~~~~~
401-
402-
Namespaces appear throughout our code, but if documentation were to show up before each occurrence of a namespace,
403-
those various bits of documentation will get bundled together by Doxygen in a manner depending on in what order it processes the files.
404-
To avoid the potential confusion there, namespaces should be documented in ``src/headers/namespaces.H``.
405-
Each namespace should be preceded by a comment block along these lines:
406-
407-
.. code-block:: cpp
408-
409-
/*!
410-
* @brief A brief description of the namespace goes here. The brief
411-
* description is terminated by a blank line.
412-
*
413-
* The detailed description of the namespace follows the blank line. This
414-
* should give an unfamiliar developer enough information to understand the
415-
* purpose of the namespace, what it contains, why it was organized in such a
416-
* way, etc.
417-
*
418-
* If the detailed description continues over multiple paragraphs, separate
419-
* paragraphs with a blank line.
420-
*/
421-
namespace something
422-
{
423-
} // end of namespace something
424-
425-
426-
``namespaces.H`` must only contain namespace (and nested namespaces) documentation, in particular no actual source code.
427-
428351
General Doxygen Guidelines
429352
~~~~~~~~~~~~~~~~~~~~~~~~~~~
430353

@@ -574,18 +497,16 @@ There are a handful of different ways to include code blocks in Doxygen, but the
574497
/*!
575498
* Here's a bit of code
576499
* \code{.cpp}
577-
int
578-
main(
579-
int argc,
580-
char* argv[])
581-
{
582-
std::cout << "Hello World!" << std::endl;
583-
} // end of main()
584-
\endcode
500+
* int
501+
* main(
502+
* int argc,
503+
* char* argv[])
504+
* {
505+
* std::cout << "Hello World!" << std::endl;
506+
* } // end of main()
507+
* \endcode
585508
* that prints "Hello World!".
586509
*/
587510
588511
The argument to the ``\code{}`` command is a file extension that'll tell Doxygen what kind of syntax highlighting it should use.
589-
Unfortunately, between the ``\code{}`` and ``\endcode`` keywords, there is no stripping of leading asterisks as would normally take place.
590-
It will, however, strip out whatever leading indentation exists.
591512

0 commit comments

Comments
 (0)