diff options
author | Mauro Carvalho Chehab <mchehab@s-opensource.com> | 2017-12-18 07:30:04 -0500 |
---|---|---|
committer | Jonathan Corbet <corbet@lwn.net> | 2017-12-21 15:41:46 -0500 |
commit | fc275bf3b99d2c78e1c132d2199be1cb6a701905 (patch) | |
tree | 0e88b84d22db6fc158668a46466c9937b029313c /Documentation/doc-guide | |
parent | 01f2c18073e284397f45c94b26e65fd1b66776e4 (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.rst | 100 |
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 | ||
200 | Function documentation | ||
201 | ---------------------- | ||
202 | |||
203 | The 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 | |||
225 | The brief description following the function name may span multiple lines, and | ||
226 | ends with an argument description, a blank comment line, or the end of the | ||
227 | comment block. | ||
228 | |||
229 | Return values | ||
230 | ~~~~~~~~~~~~~ | ||
231 | |||
232 | The return value, if any, should be described in a dedicated section | ||
233 | named ``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 | ||
201 | Highlights and cross-references | 262 | Highlights and cross-references |
202 | ------------------------------- | 263 | ------------------------------- |
@@ -269,45 +330,6 @@ cross-references. | |||
269 | 330 | ||
270 | For further details, please refer to the `Sphinx C Domain`_ documentation. | 331 | For further details, please refer to the `Sphinx C Domain`_ documentation. |
271 | 332 | ||
272 | Function documentation | ||
273 | ---------------------- | ||
274 | |||
275 | The 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 | |||
297 | The brief description following the function name may span multiple lines, and | ||
298 | ends with an ``@argument:`` description, a blank comment line, or the end of the | ||
299 | comment block. | ||
300 | |||
301 | The kernel-doc function comments describe each parameter to the function, in | ||
302 | order, with the ``@argument:`` descriptions. The ``@argument:`` descriptions | ||
303 | must begin on the very next line following the opening brief function | ||
304 | description line, with no intervening blank comment lines. The ``@argument:`` | ||
305 | descriptions may span multiple lines. The continuation lines may contain | ||
306 | indentation. If a function parameter is ``...`` (varargs), it should be listed | ||
307 | in kernel-doc notation as: ``@...:``. | ||
308 | |||
309 | The return value, if any, should be described in a dedicated section at the end | ||
310 | of the comment starting with "Return:". | ||
311 | 333 | ||
312 | Structure, union, and enumeration documentation | 334 | Structure, union, and enumeration documentation |
313 | ----------------------------------------------- | 335 | ----------------------------------------------- |