You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This style guide covers guidelines for the Doxygen-based API documentation.
126
+
This style guide covers guidelines for the doxygen-based API documentation.
92
127
93
128
General documentation guidelines
94
129
================================
95
130
96
131
#. Always use full sentences, except for descriptions for variables, structs, and enums, where sentence fragments with no verb are accepted, and always end everything with period.
97
132
#. Everything that is documented must belong to a group (see below).
98
-
#. Use capitalization sparingly; when in doubt, use lowercase. *We'll create a list of terms that should be capitalized.*
99
-
#. Line breaks: In Doxygen, break after 80 characters (following the dev guidelines). In RST, break after each sentence.
133
+
#. Use capitalization sparingly. When in doubt, use lowercase.
134
+
#. Line breaks: In doxygen, break after 80 characters (following the dev guidelines). In RST, break after each sentence.
100
135
#. **@note** and **@warning** should only be used in the details section, and only when really needed for emphasis.
101
136
Use notes for emphasis and warnings if things will really really go wrong if you ignore the warning.
102
137
103
138
File headers and groups
104
139
=======================
105
140
106
141
#. **@file** element is always required at the start of a file.
107
-
#. **There is no need to use @brief** for **@file**. *Coding Style page on Vestavind needs to be updated.*
142
+
#. There is no need to use **@brief** for **@file**.
108
143
#. **@defgroup** or **@addgroup** usually follows **@file**.
109
144
You can divide a file into several groups as well.
110
145
#. **@{** must open the group, **@}** must close it.
@@ -165,51 +200,87 @@ File headers and groups
165
200
Functions
166
201
=========
167
202
168
-
#. **Do not use @fn**. Instead, document each function where it is defined.
203
+
#. Do not use **@fn**. Instead, document each function where it is defined.
169
204
#. **@brief** is mandatory.
170
205
171
-
* Start the brief with the "do sth" form (for example, "Initialize the module", "Send Boot Keyboard Input Report").
206
+
* Start the brief with the "do sth" form.
207
+
208
+
.. code-block:: none
209
+
:caption: Brief documentation examples
210
+
211
+
/** @brief Request a read operation to be executed from Secure Firmware.
212
+
213
+
/** @brief Send Boot Keyboard Input Report.
172
214
173
215
#. **@details** is optional.
174
216
It can be introduced either by using **@details** or by leaving a blank line after **@brief**.
175
217
#. **@param** should be used for every parameter.
176
218
177
219
* Always add parameter description.
178
220
Use a sentence fragment (no verb) with period at the end.
179
-
* Specify for all parameters whether they are ``[in]``, ``[out]``, or ``[in,out]``. *- TBD*
221
+
* Make sure the parameter documentation within the function is consistently using the parameter type: ``[in]``, ``[out]``, or ``[in,out]``.
222
+
223
+
.. code-block:: none
224
+
:caption: Parameter documentation example
225
+
226
+
* @param[out] destination Pointer to destination array where the content is
227
+
* to be copied.
228
+
* @param[in] addr Address to be copied from.
229
+
* @param[in] len Number of bytes to copy.
180
230
181
231
#. If you include more than one **@sa** ("see also", optional), add them this way::
182
232
183
233
@sa first_function
184
234
@sa second_function
185
235
186
-
#. **@return** should be used to describe a return value (for example, "@return The length of ...", "@return The handle").
236
+
#. **@return** should be used to describe a generic return value without a specific value (for example, "@return The length of ...", "@return The handle").
187
237
There is usually only one return value.
238
+
239
+
.. code-block:: none
240
+
:caption: Return documentation example
241
+
242
+
* @return Initializer that sets up the pipe, length, and byte array for
243
+
* content of the TX data.
244
+
188
245
#. **@retval** should be used for specific return values (for example, "@retval true", "@retval CONN_ERROR").
189
246
Describe the condition for each of the return values (for example, "If the function completes successfully", "If the connection cannot be established").
190
-
If there is only one retval, add what happens otherwise. Example: "Otherwise, an error code is returned".
191
-
#. **Do not use @returns**.
247
+
248
+
.. code-block:: none
249
+
:caption: Retval documentation example
250
+
251
+
* @retval 0 If the operation was successful.
252
+
* Otherwise, a (negative) error code is returned.
253
+
* @retval (-ENOTSUP) Special error code used when the UUID
254
+
* of the service does not match the expected UUID.
255
+
256
+
#. Do not use **@returns**.
192
257
Use **@return** instead.
193
258
194
259
.. code-block:: c
195
-
:caption: Function documentation example
196
-
197
-
/** @brief Send Boot Keyboard Input Report.
198
-
*
199
-
* @param hids_obj HIDS instance.
200
-
* @param rep Pointer to the report data.
201
-
* @param len Length of report data.
202
-
*
203
-
* @retval 0 If the operation was successful.
204
-
* Otherwise, a (negative) error code is returned.
205
-
*/
206
-
int hids_boot_kb_inp_rep_send(struct hids *hids_obj, u8_t const *rep,
207
-
u16_t len);
260
+
:caption: Complete function documentation example
261
+
262
+
/** @brief Request a random number from the Secure Firmware.
263
+
*
264
+
* This function provides a True Random Number from the on-board random number generator.
265
+
*
266
+
* @note Currently, the RNG hardware is run each time this function is called. This
267
+
* consumes significant time and power.
268
+
*
269
+
* @param[out] output The random number. Must be at least @p len long.
270
+
* @param[in] len The length of the output array. Currently, @p len must be
271
+
* 144.
272
+
* @param[out] olen The length of the random number provided.
273
+
*
274
+
* @retval 0 If the operation was successful.
275
+
* @retval -EINVAL If @p len is invalid. Currently, @p len must be 144.
276
+
*/
277
+
int spm_request_random_number(u8_t *output, size_t len, size_t *olen);
208
278
209
279
Enums
210
280
=====
211
281
212
282
The documentation block should precede the documented element.
283
+
This is in accordance with the `Zephyr coding style`_.
213
284
214
285
215
286
.. code-block:: c
@@ -229,6 +300,7 @@ Structs
229
300
=======
230
301
231
302
The documentation block should precede the documented element.
303
+
This is in accordance with the `Zephyr coding style`_.
232
304
Make sure to add ``:members:`` when you include the API documentation in RST; otherwise, the member documentation will not show up.
233
305
234
306
.. code-block:: c
@@ -248,43 +320,52 @@ Make sure to add ``:members:`` when you include the API documentation in RST; ot
248
320
const struct event_type *type_id;
249
321
};
250
322
323
+
324
+
.. note::
325
+
Always add a name for the struct.
326
+
Avoid using unnamed structs due to `Sphinx parser issue`_.
327
+
328
+
251
329
References
252
330
==========
253
331
254
-
To link to functions, enums, or structs from within Doxygen itself, use the
332
+
To link to functions, enums, or structs from within doxygen itself, use the
255
333
``@ref`` keyword.
256
334
257
-
.. code-block:: c
335
+
.. code-block:: none
258
336
:caption: Reference documentation example
259
337
260
-
/** @brief Event header structure.
261
-
* Use this structure with the function @ref function_name and
262
-
* this structure is related to another structure, @ref structure_name.
263
-
*/
338
+
/** @brief Event header structure.
339
+
* Use this structure with the function @ref function_name and
340
+
* this structure is related to another structure, @ref structure_name.
341
+
*/
264
342
265
343
.. note::
266
-
Linking to functions does not currently work due to `breathe issue #438`_.
344
+
Linking to functions does not currently work due to `Breathe issue #438`_.
267
345
268
346
269
-
Typedefs - WIP
270
-
==============
347
+
Typedefs
348
+
========
271
349
272
-
#. The documentation block should follow, not precede, the documented element.
273
-
#. The C99-style single line comment, ``//``, is not allowed, as per `Zephyr coding style`_.
350
+
The documentation block should precede the documented element.
351
+
This is in accordance with the `Zephyr coding style`_.
274
352
275
353
.. code-block:: c
276
-
:caption: Typedef documentation example -- PH
277
-
278
-
TBD
279
-
280
-
TBD
281
-
==============
282
-
283
-
@def, @fn should not be used for defines or functions; Zephyr seems to require this but we should be ok without this.
284
-
Just use a @brief and let doxygen figure out what exactly you are documenting.
285
-
286
-
For parameters, it is recommended to specify whether they are [in], [out], or [in,out].
287
-
If you specify this for one parameter in a function, all others must have it as well, for consistency. *To be discussed if this should be a requirement.*
0 commit comments