Skip to content

Commit 94afe6a

Browse files
unicornxRbb666
authored andcommitted
doxygen: improve howto
- Add description on how to group macros. - Add description for structs on how to write comments for members when the name of member is too. - Use @ref to link group instead of the html filenames. Signed-off-by: Chen Wang <[email protected]>
1 parent b506228 commit 94afe6a

File tree

7 files changed

+82
-32
lines changed

7 files changed

+82
-32
lines changed

documentation/0.doxygen/example/include/enum.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@
1616
* <a href="https://github.com/RT-Thread/rt-thread/blob/master/documentation/0.doxygen/example/include/enum.h">documentation/0.doxygen/example/include/enum.h</a>
1717
* for code example.
1818
*
19-
* See
20-
* <a href="./group__group__doxygen__example__enum.html">Doxygen Example of Enumeration</a>
21-
* for html output.
19+
* See @ref group_doxygen_example_enum for html output.
2220
*/
2321

2422
/**

documentation/0.doxygen/example/include/groups.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@
2626
* <a href="https://github.com/RT-Thread/rt-thread/blob/master/documentation/0.doxygen/example/include/groups.h">documentation/0.doxygen/example/include/groups.h</a>
2727
* for code example.
2828
*
29-
* See
30-
* <a href="./group__group__doxygen__example__sub.html">Doxygen Example of Groups and Sub-Groups</a>
31-
* for html output.
29+
* See @ref group_doxygen_example for html output.
3230
*
3331
* More information can be found in the Doxygen manual:
3432
* <a href="https://www.doxygen.nl/manual/grouping.html">Grouping</a>.

documentation/0.doxygen/example/include/macro.h

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,14 @@
2020
* <a href="https://github.com/RT-Thread/rt-thread/blob/master/documentation/0.doxygen/example/include/macro.h">documentation/0.doxygen/example/include/macro.h</a>
2121
* for code example.
2222
*
23-
* See
24-
* <a href="./group__group__doxygen__example__macro.html">Doxygen Example of Macro</a>
25-
* for html output.
23+
* We often categorize macros in our code. Similarly, when writing doxygen
24+
* comments for these categorized macros, we can also group them. See
25+
* `DOXYGEN_EXAMPLE_GROUP_A_X`/`DOXYGEN_EXAMPLE_GROUP_A_Y` and
26+
* `DOXYGEN_EXAMPLE_GROUP_B_X`/`DOXYGEN_EXAMPLE_GROUP_B_Y` in
27+
* <a href="https://github.com/RT-Thread/rt-thread/blob/master/documentation/0.doxygen/example/include/macro.h">documentation/0.doxygen/example/include/macro.h</a>
28+
* for code example.
29+
*
30+
* See @ref group_doxygen_example_macro for html output.
2631
*/
2732

2833
/**
@@ -47,6 +52,28 @@
4752
*/
4853
#define DOXYGEN_EXAMPLE_ABS(x) (((x)>0)?(x):-(x))
4954

55+
/**
56+
* @defgroup group_doxygen_example_macro_group_a Group A of Macros
57+
*
58+
* @brief Doxygen Example of Macros grouped in A.
59+
*
60+
* @{
61+
*/
62+
#define DOXYGEN_EXAMPLE_GROUP_A_X 0x0000 /**< Description of X in group A */
63+
#define DOXYGEN_EXAMPLE_GROUP_A_Y 0x0001 /**< Description of Y in group A */
64+
/** @} */
65+
66+
/**
67+
* @defgroup group_doxygen_example_macro_group_b Group B of Macros
68+
*
69+
* @brief Doxygen Example of Macros grouped in B
70+
*
71+
* @{
72+
*/
73+
#define DOXYGEN_EXAMPLE_GROUP_B_X 0x0000 /**< Description of X in group B */
74+
#define DOXYGEN_EXAMPLE_GROUP_B_Y 0x0001 /**< Description of Y in group B */
75+
/** @} */
76+
5077
/** @} */
5178

5279
#endif

documentation/0.doxygen/example/include/struct.h

Lines changed: 47 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,24 @@
1515
* can add a detailed description part, which is also optional.
1616
*
1717
* Put member comments inside the structure definition and after every member.
18+
* See `struct dogygen_example_struct` for example.
19+
*
20+
* If the structure member is too long (this often happens when the structure
21+
* member is a callback function), when the comment is written after the member,
22+
* it will make the code line too long. In this case, we can also put the comment
23+
* before the member. See `struct dogygen_example_struct_another` for example.
24+
*
25+
* Going a step further, for this kind of structure whose members are callback
26+
* functions, we can describe the members in style for functions, it is more
27+
* complicated and contains more content. It is useful when we want to describe
28+
* the parameters and return values ​​of the callback function in more detail.
29+
* See `struct dogygen_example_struct_another2` for example.
1830
*
1931
* See
2032
* <a href="https://github.com/RT-Thread/rt-thread/blob/master/documentation/0.doxygen/example/include/struct.h">documentation/0.doxygen/example/include/struct.h</a>
2133
* for code example.
2234
*
23-
* See
24-
* <a href="./group__group__doxygen__example__struct.html">Doxygen Example of Structure</a>
25-
* for html output.
35+
* See @ref group_doxygen_example_struct for html output.
2636
*/
2737

2838
/**
@@ -68,17 +78,40 @@ struct dogygen_example_struct
6878
*/
6979
struct dogygen_example_struct_another
7080
{
71-
int m1; /**< Some documentation for member 'm1'...
72-
* Multiple lines ... Note the "multi-line" here refers
73-
* to the code. Whether it is displayed in multiple lines
74-
* on the specific HTML page depends on the browser rendering.
75-
*
76-
* @note We can also embed note for member 'm1'...
77-
*/
78-
int m2; /**< Some documentation for member 'm2'... */
79-
int m3; /**< Some documentation for member 'm3'... */
80-
int m4; /**< Some documentation for member 'm4'... */
81-
int m5; /**< Some documentation for member 'm5'... */
81+
/** Some documentation for member 'm1'... */
82+
int (*m1)(int *param1, int param2, int param3, int param4);
83+
/** Some documentation for member 'm2'... */
84+
int (*m2)(int *param1, int param2, int param3, int param4);
85+
};
86+
87+
/**
88+
* @brief Brief description this structure
89+
*
90+
* Detailed description starts here, one line or multiple lines.
91+
* Blah blah blah...
92+
*
93+
* @note This is a note for this structure, blah blah blah...
94+
*/
95+
struct dogygen_example_struct_another2
96+
{
97+
/**
98+
* @brief Brief description of m1
99+
* @param param1 The first param.
100+
* @param param2 The second param.
101+
* @param param3 The third param.
102+
* @param param4 The fourth param.
103+
* @return the operation status, 0 on successful
104+
*/
105+
int (*m1)(int *param1, int param2, int param3, int param4);
106+
/**
107+
* @brief Brief description of m2
108+
* @param param1 The first param.
109+
* @param param2 The second param.
110+
* @param param3 The third param.
111+
* @param param4 The fourth param.
112+
* @return the operation status, 0 on successful
113+
*/
114+
int (*m2)(int *param1, int param2, int param3, int param4);
82115
};
83116

84117
/** @} */

documentation/0.doxygen/example/include/typedef.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@
2828
* <a href="https://github.com/RT-Thread/rt-thread/blob/master/documentation/0.doxygen/example/include/typedef.h">documentation/0.doxygen/example/include/typedef.h</a>
2929
* for code example.
3030
*
31-
* See
32-
* <a href="./group__group__doxygen__example__typedef.html">Doxygen Example of Typedef</a>
33-
* for html output.
31+
* See @ref group_doxygen_example_typedef for html output.
3432
*/
3533

3634
#include "struct.h"

documentation/0.doxygen/example/include/union.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@
1616
* <a href="https://github.com/RT-Thread/rt-thread/blob/master/documentation/0.doxygen/example/include/union.h">documentation/0.doxygen/example/include/union.h</a>
1717
* for code example.
1818
*
19-
* See
20-
* <a href="./group__group__doxygen__example__union.html">Doxygen Example of Union</a>
21-
* for html output.
19+
* See @ref group_doxygen_example_union for html output.
2220
*/
2321

2422
/**

documentation/0.doxygen/example/src/function.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,7 @@
4545
* <a href="https://github.com/RT-Thread/rt-thread/blob/master/documentation/0.doxygen/example/src/function.c">documentation/0.doxygen/example/src/function.c</a>
4646
* for code example.
4747
*
48-
* See
49-
* <a href="./group__group__doxygen__example__function.html">Doxygen Example of Function</a>
50-
* for html output.
48+
* See @ref group_doxygen_example_function for html output.
5149
*
5250
* @note <a href="https://github.com/RT-Thread/rt-thread/blob/master/documentation/0.doxygen/example/src/function.h">documentation/0.doxygen/example/src/function.h</a>
5351
* is just an example of the header file where we declare the API without

0 commit comments

Comments
 (0)