1 | .. SPDX-License-Identifier: CC-BY-SA-4.0 |
---|
2 | |
---|
3 | .. Copyright (C) 2019 embedded brains GmbH |
---|
4 | |
---|
5 | Doxygen Guidelines |
---|
6 | ================== |
---|
7 | |
---|
8 | Group Names |
---|
9 | ----------- |
---|
10 | |
---|
11 | Doxygen group names shall use |
---|
12 | `CamelCase <https://en.wikipedia.org/wiki/Camel_case>`_. |
---|
13 | In the RTEMS source code, CamelCase is rarely used, so this makes it easier to |
---|
14 | search and replace Doxygen groups. It avoids ambiguous references to |
---|
15 | functions, types, defines, macros, and groups. All groups shall have an |
---|
16 | ``RTEMS`` prefix. This makes it possible to include the RTEMS files with |
---|
17 | Doxygen comments in a larger project without name conflicts. |
---|
18 | |
---|
19 | .. code:: c |
---|
20 | |
---|
21 | /** |
---|
22 | * @defgroup RTEMSScoreThread |
---|
23 | * |
---|
24 | * @ingrop RTEMSScore |
---|
25 | * |
---|
26 | * ... |
---|
27 | */ |
---|
28 | |
---|
29 | Use Groups |
---|
30 | ---------- |
---|
31 | |
---|
32 | Every file, function declaration, type definition, typedef, define, macro and |
---|
33 | global variable declaration shall belong to at least one Doxygen group. Use |
---|
34 | ``@defgroup`` and ``@addtogroup`` with ``@{`` and ``@}`` brackets to add |
---|
35 | members to a group. A group shall be defined at most once. Each group shall |
---|
36 | be documented with an ``@brief`` description and an optional detailed |
---|
37 | description. The ``@brief`` description shall use |
---|
38 | `Title Case <https://en.wikipedia.org/wiki/Letter_case#Title_Case>`_. |
---|
39 | Use grammatically correct sentences for the detailed descriptions. |
---|
40 | |
---|
41 | .. code:: c |
---|
42 | |
---|
43 | /** |
---|
44 | * @defgroup RTEMSScoreThread |
---|
45 | * |
---|
46 | * @ingrop RTEMSScore |
---|
47 | * |
---|
48 | * @brief Thread Handler |
---|
49 | * |
---|
50 | * ... |
---|
51 | * |
---|
52 | * @{ |
---|
53 | */ |
---|
54 | |
---|
55 | ... declarations, defines ... |
---|
56 | |
---|
57 | /** @} */ |
---|
58 | |
---|
59 | .. code:: c |
---|
60 | |
---|
61 | /** |
---|
62 | * @addtogroup RTEMSScoreThread |
---|
63 | * |
---|
64 | * @{ |
---|
65 | */ |
---|
66 | |
---|
67 | ... declarations, defines ... |
---|
68 | |
---|
69 | /** @} */ |
---|
70 | |
---|
71 | Files |
---|
72 | ----- |
---|
73 | |
---|
74 | Each source or header file shall have an ``@file`` block at the top of the |
---|
75 | file. The ``@file`` block should precede the license header separated by one |
---|
76 | blank line. This placement reduces the chance of merge conflicts in imported |
---|
77 | third-party code. The ``@file`` block shall be put into a group with |
---|
78 | ``@ingroup GroupName``. The ``@file`` block should have an ``@brief`` |
---|
79 | description and a detailed description if it is considered helpful. Use |
---|
80 | ``@brief @copybrief GroupName`` as a default to copy the ``@brief`` description |
---|
81 | from the corresponding group and omit the detailed description. |
---|
82 | |
---|
83 | .. code:: c |
---|
84 | |
---|
85 | /** |
---|
86 | * @file |
---|
87 | * |
---|
88 | * @ingroup RTEMSScoreThread |
---|
89 | * |
---|
90 | * @brief @copybrief RTEMSScoreThread |
---|
91 | */ |
---|
92 | |
---|
93 | .. code:: c |
---|
94 | |
---|
95 | /** |
---|
96 | * @file |
---|
97 | * |
---|
98 | * @ingroup RTEMSScoreThread |
---|
99 | * |
---|
100 | * @brief Some helpful brief description. |
---|
101 | * |
---|
102 | * Some helpful detailed description. |
---|
103 | */ |
---|
104 | |
---|
105 | Type Definitions |
---|
106 | ---------------- |
---|
107 | |
---|
108 | Each type defined in a header file shall be documented with an ``@brief`` |
---|
109 | description and an optional detailed description. Each type member shall be |
---|
110 | documented with an ``@brief`` description and an optional detailed description. |
---|
111 | Use grammatically correct sentences for the detailed descriptions. |
---|
112 | |
---|
113 | .. code:: c |
---|
114 | |
---|
115 | /** |
---|
116 | * @brief The information structure used to manage each API class of objects. |
---|
117 | * |
---|
118 | * If objects for the API class are configured, an instance of this structure |
---|
119 | * is statically allocated and pre-initialized by OBJECTS_INFORMATION_DEFINE() |
---|
120 | * through <rtems/confdefs.h>. The RTEMS library contains a statically |
---|
121 | * allocated and pre-initialized instance for each API class providing zero |
---|
122 | * objects, see OBJECTS_INFORMATION_DEFINE_ZERO(). |
---|
123 | */ |
---|
124 | typedef struct { |
---|
125 | /** |
---|
126 | * @brief This is the maximum valid ID of this object API class. |
---|
127 | * |
---|
128 | * This member is statically initialized and provides also the object API, |
---|
129 | * class and multiprocessing node information. |
---|
130 | * |
---|
131 | * It is used by _Objects_Get() to validate an object ID. |
---|
132 | */ |
---|
133 | Objects_Id maximum_id; |
---|
134 | |
---|
135 | ... more members ... |
---|
136 | } Objects_Information; |
---|
137 | |
---|
138 | Function Declarations |
---|
139 | --------------------- |
---|
140 | |
---|
141 | Each function declaration or function-like macros in a header file shall be |
---|
142 | documented with an ``@brief`` description and an optional detailed description. |
---|
143 | Use grammatically correct sentences for the brief and detailed descriptions. |
---|
144 | Each parameter shall be documented with an ``@param`` entry. List the |
---|
145 | ``@param`` entries in the order of the function parameters. For *non-const |
---|
146 | pointer* parameters |
---|
147 | |
---|
148 | * use ``@param[out]``, if the referenced object is modified by the function, or |
---|
149 | |
---|
150 | * use ``@param[in, out]``, if the referenced object is read and modified by the |
---|
151 | function. |
---|
152 | |
---|
153 | For other parameters (e.g. *const pointer* and *scalar* parameters) do not use |
---|
154 | the ``[in]``, ``[out]`` or ``[in, out]`` parameter specifiers. Each return |
---|
155 | value or return value range shall be documented with an ``@retval`` entry. |
---|
156 | Document the most common return value first. Use a placeholder name for value |
---|
157 | ranges, e.g. ``pointer`` in the ``_Workspace_Allocate()`` example below. In |
---|
158 | case the function returns only one value, then use ``@return``, e.g. use |
---|
159 | ``@retval`` only if there are at least two return values or return value |
---|
160 | ranges. Use grammatically correct sentences for the parameter and return value |
---|
161 | descriptions. |
---|
162 | |
---|
163 | .. code:: c |
---|
164 | |
---|
165 | /** |
---|
166 | * @brief Sends a message to the message queue. |
---|
167 | * |
---|
168 | * This directive sends the message buffer to the message queue indicated by |
---|
169 | * ID. If one or more tasks is blocked waiting to receive a message from this |
---|
170 | * message queue, then one will receive the message. The task selected to |
---|
171 | * receive the message is based on the task queue discipline algorithm in use |
---|
172 | * by this particular message queue. If no tasks are waiting, then the message |
---|
173 | * buffer will be placed at the rear of the chain of pending messages for this |
---|
174 | * message queue. |
---|
175 | * |
---|
176 | * @param id The message queue ID. |
---|
177 | * @param buffer The message content buffer. |
---|
178 | * @param size The size of the message. |
---|
179 | * |
---|
180 | * @retval RTEMS_SUCCESSFUL Successful operation. |
---|
181 | * @retval RTEMS_INVALID_ID Invalid message queue ID. |
---|
182 | * @retval RTEMS_INVALID_ADDRESS The message buffer pointer is @c NULL. |
---|
183 | * @retval RTEMS_INVALID_SIZE The message size is larger than the maximum |
---|
184 | * message size of the message queue. |
---|
185 | * @retval RTEMS_TOO_MANY The new message would exceed the message queue limit |
---|
186 | * for pending messages. |
---|
187 | */ |
---|
188 | rtems_status_code rtems_message_queue_send( |
---|
189 | rtems_id id, |
---|
190 | const void *buffer, |
---|
191 | size_t size |
---|
192 | ); |
---|
193 | |
---|
194 | .. code:: c |
---|
195 | |
---|
196 | /** |
---|
197 | * @brief Receives a message from the message queue |
---|
198 | * |
---|
199 | * This directive is invoked when the calling task wishes to receive a message |
---|
200 | * from the message queue indicated by ID. The received message is to be placed |
---|
201 | * in the buffer. If no messages are outstanding and the option set indicates |
---|
202 | * that the task is willing to block, then the task will be blocked until a |
---|
203 | * message arrives or until, optionally, timeout clock ticks have passed. |
---|
204 | * |
---|
205 | * @param id The message queue ID. |
---|
206 | * @param[out] buffer The buffer for the message content. The buffer must be |
---|
207 | * large enough to store maximum size messages of this message queue. |
---|
208 | * @param[out] size The size of the message. |
---|
209 | * @param option_set The option set, e.g. RTEMS_NO_WAIT or RTEMS_WAIT. |
---|
210 | * @param timeout The number of ticks to wait if the RTEMS_WAIT is set. Use |
---|
211 | * RTEMS_NO_TIMEOUT to wait indefinitely. |
---|
212 | * |
---|
213 | * @retval RTEMS_SUCCESSFUL Successful operation. |
---|
214 | * @retval RTEMS_INVALID_ID Invalid message queue ID. |
---|
215 | * @retval RTEMS_INVALID_ADDRESS The message buffer pointer or the message size |
---|
216 | * pointer is @c NULL. |
---|
217 | * @retval RTEMS_TIMEOUT A timeout occurred and no message was received. |
---|
218 | */ |
---|
219 | rtems_status_code rtems_message_queue_receive( |
---|
220 | rtems_id id, |
---|
221 | void *buffer, |
---|
222 | size_t *size, |
---|
223 | rtems_option option_set, |
---|
224 | rtems_interval timeout |
---|
225 | ); |
---|
226 | |
---|
227 | .. code:: c |
---|
228 | |
---|
229 | /** |
---|
230 | * @brief Allocates a memory block of the specified size from the workspace. |
---|
231 | * |
---|
232 | * @param size The size of the memory block. |
---|
233 | * |
---|
234 | * @retval pointer The pointer to the memory block. The pointer is at least |
---|
235 | * aligned by CPU_HEAP_ALIGNMENT. |
---|
236 | * @retval NULL No memory block with the requested size is available in the |
---|
237 | * workspace. |
---|
238 | */ |
---|
239 | void *_Workspace_Allocate( size_t size ); |
---|
240 | |
---|
241 | .. code:: c |
---|
242 | |
---|
243 | /** |
---|
244 | * @brief Rebalances the red-black tree after insertion of the node. |
---|
245 | * |
---|
246 | * @param[in, out] the_rbtree The red-black tree control. |
---|
247 | * @param[in, out] the_node The most recently inserted node. |
---|
248 | */ |
---|
249 | void _RBTree_Insert_color( |
---|
250 | RBTree_Control *the_rbtree, |
---|
251 | RBTree_Node *the_node |
---|
252 | ); |
---|
253 | |
---|
254 | .. code:: c |
---|
255 | |
---|
256 | /** |
---|
257 | * @brief Builds an object ID from its components. |
---|
258 | * |
---|
259 | * @param the_api The object API. |
---|
260 | * @param the_class The object API class. |
---|
261 | * @param node The object node. |
---|
262 | * @param index The object index. |
---|
263 | * |
---|
264 | * @return Returns the object ID constructed from the arguments. |
---|
265 | */ |
---|
266 | #define _Objects_Build_id( the_api, the_class, node, index ) |
---|
267 | |
---|
268 | Header File Examples |
---|
269 | -------------------- |
---|
270 | |
---|
271 | The |
---|
272 | `<rtems/score/thread.h> <https://git.rtems.org/rtems/tree/cpukit/include/rtems/score/thread.h>`_ |
---|
273 | and |
---|
274 | `<rtems/score/threadimpl.h> <https://git.rtems.org/rtems/tree/cpukit/include/rtems/score/threadimpl.h>`_ |
---|
275 | header files are a good example of how header files should be documented. |
---|