History

Kernel-doc: Convention: Use a "Return" section to describe return values

Non-void functions should describe their return values in their kernel-doc comments. Currently, some don't, others do in various forms. For example: * Return the result. * Return: The result. * Returns the result. * Returns: the result. * Return Value: The result. * @return: the result. * This function returns the result. * It will return the result. Defining a convention would improve consistency of kernel-doc comments. It would also help scripts/kernel-doc identify the text describing the return value of a function. Thus allowing additional checks on the comments, and suitable highlighting in the generated docs (man pages, html, etc). So, as a convention, use a section named "Return" to describe the return value of a function.

Yacine Belkadi committed 13 years ago

Commit ddf5eab1 parent ddffeb81 file · +10 −3Browse files

Unified · Split

Documentation/kernel-doc-nano-HOWTO.txt+10−3
@@ -64,6 +64,8 @@ Example kernel-doc function comment: · 63 unmodified lines
6464 * comment lines.
6565 *
6666 * The longer description can have multiple paragraphs.
67+ *
68+ * Return: Describe the return value of foobar.
6769 */
6870
6971 The short description following the subject can span multiple lines
@@ -78,6 +80,8 @@ If a function parameter is "..." (varargs), it should be listed in · 8 unmodified lines
7880 kernel-doc notation as:
7981 * @...: description
8082
83+The return value, if any, should be described in a dedicated section
84+named "Return".
8185
8286 Example kernel-doc data structure comment.
8387
@@ -222,6 +226,9 @@ only a "*"). · 138 unmodified lines
222226 "section header:" names must be unique per function (or struct,
223227 union, typedef, enum).
224228
229+Use the section header "Return" for sections describing the return value
230+of a function.
231+
225232 Avoid putting a spurious blank line after the function name, or else the
226233 description will be repeated!
227234
@@ -237,21 +244,21 @@ patterns, which are highlighted appropriately. · 9 unmodified lines
237244 NOTE 1: The multi-line descriptive text you provide does *not* recognize
238245 line breaks, so if you try to format some text nicely, as in:
239246
240− Return codes
247+ Return:
241248 0 - cool
242249 1 - invalid arg
243250 2 - out of memory
244251
245252 this will all run together and produce:
246253
247− Return codes 0 - cool 1 - invalid arg 2 - out of memory
254+ Return: 0 - cool 1 - invalid arg 2 - out of memory
248255
249256 NOTE 2: If the descriptive text you provide has lines that begin with
250257 some phrase followed by a colon, each of those phrases will be taken as
251258 a new section heading, which means you should similarly try to avoid text
252259 like:
253260
254− Return codes:
261+ Return:
255262 0: cool
256263 1: invalid arg
257264 2: out of memory