summaryrefslogtreecommitdiffstats
path: root/Documentation/doc-guide
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@s-opensource.com>2017-12-18 07:30:04 -0500
committerJonathan Corbet <corbet@lwn.net>2017-12-21 15:41:46 -0500
commitfc275bf3b99d2c78e1c132d2199be1cb6a701905 (patch)
tree0e88b84d22db6fc158668a46466c9937b029313c /Documentation/doc-guide
parent01f2c18073e284397f45c94b26e65fd1b66776e4 (diff)
docs: kernel-doc.rst: improve function documentation section
Move its contents to happen earlier and improve the description of return values, adding a subsection to it. Most of the contents there came from kernel-doc-nano-HOWTO.txt. Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com> Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Diffstat (limited to 'Documentation/doc-guide')
-rw-r--r--Documentation/doc-guide/kernel-doc.rst100
1 files changed, 61 insertions, 39 deletions
diff --git a/Documentation/doc-guide/kernel-doc.rst b/Documentation/doc-guide/kernel-doc.rst
index 7cf58c3489de..3aac228fc346 100644
--- a/Documentation/doc-guide/kernel-doc.rst
+++ b/Documentation/doc-guide/kernel-doc.rst
@@ -197,6 +197,67 @@ Example::
197 int d; 197 int d;
198 }; 198 };
199 199
200Function documentation
201----------------------
202
203The general format of a function and function-like macro kernel-doc comment is::
204
205 /**
206 * function_name() - Brief description of function.
207 * @arg1: Describe the first argument.
208 * @arg2: Describe the second argument.
209 * One can provide multiple line descriptions
210 * for arguments.
211 *
212 * A longer description, with more discussion of the function function_name()
213 * that might be useful to those using or modifying it. Begins with an
214 * empty comment line, and may include additional embedded empty
215 * comment lines.
216 *
217 * The longer description may have multiple paragraphs.
218 *
219 * Return: Describe the return value of foobar.
220 *
221 * The return value description can also have multiple paragraphs, and should
222 * be placed at the end of the comment block.
223 */
224
225The brief description following the function name may span multiple lines, and
226ends with an argument description, a blank comment line, or the end of the
227comment block.
228
229Return values
230~~~~~~~~~~~~~
231
232The return value, if any, should be described in a dedicated section
233named ``Return``.
234
235.. note::
236
237 #) The multi-line descriptive text you provide does *not* recognize
238 line breaks, so if you try to format some text nicely, as in::
239
240 * Return:
241 * 0 - OK
242 * -EINVAL - invalid argument
243 * -ENOMEM - out of memory
244
245 this will all run together and produce::
246
247 Return: 0 - OK -EINVAL - invalid argument -ENOMEM - out of memory
248
249 So, in order to produce the desired line breaks, you need to use a
250 ReST list, e. g.::
251
252 * Return:
253 * * 0 - OK to runtime suspend the device
254 * * -EBUSY - Device should not be runtime suspended
255
256 #) If the descriptive text you provide has lines that begin with
257 some phrase followed by a colon, each of those phrases will be taken
258 as a new section heading, with probably won't produce the desired
259 effect.
260
200 261
201Highlights and cross-references 262Highlights and cross-references
202------------------------------- 263-------------------------------
@@ -269,45 +330,6 @@ cross-references.
269 330
270For further details, please refer to the `Sphinx C Domain`_ documentation. 331For further details, please refer to the `Sphinx C Domain`_ documentation.
271 332
272Function documentation
273----------------------
274
275The general format of a function and function-like macro kernel-doc comment is::
276
277 /**
278 * function_name() - Brief description of function.
279 * @arg1: Describe the first argument.
280 * @arg2: Describe the second argument.
281 * One can provide multiple line descriptions
282 * for arguments.
283 *
284 * A longer description, with more discussion of the function function_name()
285 * that might be useful to those using or modifying it. Begins with an
286 * empty comment line, and may include additional embedded empty
287 * comment lines.
288 *
289 * The longer description may have multiple paragraphs.
290 *
291 * Return: Describe the return value of foobar.
292 *
293 * The return value description can also have multiple paragraphs, and should
294 * be placed at the end of the comment block.
295 */
296
297The brief description following the function name may span multiple lines, and
298ends with an ``@argument:`` description, a blank comment line, or the end of the
299comment block.
300
301The kernel-doc function comments describe each parameter to the function, in
302order, with the ``@argument:`` descriptions. The ``@argument:`` descriptions
303must begin on the very next line following the opening brief function
304description line, with no intervening blank comment lines. The ``@argument:``
305descriptions may span multiple lines. The continuation lines may contain
306indentation. If a function parameter is ``...`` (varargs), it should be listed
307in kernel-doc notation as: ``@...:``.
308
309The return value, if any, should be described in a dedicated section at the end
310of the comment starting with "Return:".
311 333
312Structure, union, and enumeration documentation 334Structure, union, and enumeration documentation
313----------------------------------------------- 335-----------------------------------------------