Skip to content

Commit 57fad5c

Browse files
committed
C, update documentation for info-fields
1 parent 65aa3f7 commit 57fad5c

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

doc/usage/restructuredtext/domains.rst

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -677,12 +677,55 @@ The C domain (name **c**) is suited for documentation of C API.
677677
Note that you don't have to backslash-escape asterisks in the signature, as
678678
it is not parsed by the reST inliner.
679679

680+
In the description of a function you can use the following info-fields
681+
(see also :ref:`info-field-lists`).
682+
683+
* ``param``, ``parameter``, ``arg``, ``argument``,
684+
Description of a parameter.
685+
* ``type``: Type of a parameter,
686+
written as if passed to the :rst:role:`c:expr` role.
687+
* ``returns``, ``return``: Description of the return value.
688+
* ``rtype``: Return type,
689+
written as if passed to the :rst:role:`c:expr` role.
690+
* ``retval``, ``retvals``: An alternative to ``returns`` for describing
691+
the result of the function.
692+
693+
.. versionadded:: 4.3
694+
The ``retval`` field type.
695+
696+
For example::
697+
698+
.. c:function:: PyObject *PyType_GenericAlloc(PyTypeObject *type, Py_ssize_t nitems)
699+
700+
:param type: description of the first parameter.
701+
:param nitems: description of the second parameter.
702+
:returns: a result.
703+
:retval NULL: under some conditions.
704+
:retval NULL: under some other conditions as well.
705+
706+
which renders as
707+
708+
.. c:function:: PyObject *PyType_GenericAlloc(PyTypeObject *type, Py_ssize_t nitems)
709+
710+
..
711+
** for some editors (e.g., vim) to stop bold-highlighting the source
712+
713+
:param type: description of the first parameter.
714+
:param nitems: description of the second parameter.
715+
:returns: a result.
716+
:retval NULL: under some conditions.
717+
:retval NULL: under some other conditions as well.
718+
719+
680720
.. rst:directive:: .. c:macro:: name
681721
.. c:macro:: name(arg list)
682722
683723
Describes a C macro, i.e., a C-language ``#define``, without the replacement
684724
text.
685725
726+
In the description of a macro you can use the same info-fields as for the
727+
:rst:dir:`c:function` directive.
728+
686729
.. versionadded:: 3.0
687730
The function style variant.
688731

0 commit comments

Comments
 (0)