The name of the default domain. Can also be None to disable a default domain. The default is ‘py’. Those objects in other domains (whether the domain name is given explicitly, or selected by a default-domain directive) will have the domain name explicitly prepended when named (e.g., when the default domain is C, Python functions will be named “Python function”, not just “function”).
See also
Contents
.. default-domain:: C
The C domain (name c) is suited for documentation of C API.
-
.. c:function::
type name(signature)
¶
Describes a C function. The signature should be given as in C, e.g.:
.. c:function:: PyObject* PyType_GenericAlloc(PyTypeObject *type, Py_ssize_t nitems)
-
PyObject *
PyType_GenericAlloc
(PyTypeObject *type, Py_ssize_t nitems)¶
This is also used to describe function-like preprocessor macros. The names of the arguments should be given so they may be used in the description.
Note that you don’t have to backslash-escape asterisks in the signature, as it is not parsed by the reST inliner.
Describes a C struct member. Example signature:
.. c:member:: PyObject* PyTypeObject.tp_bases
The text of the description should include the range of values allowed, how
the value should be interpreted, and whether the value can be changed.
References to structure members in text should use the member
role.
.. rst:directive:: .. c:macro:: name
Describes a “simple” C macro. Simple macros are macros which are used for
code expansion, but which do not take arguments so cannot be described as
functions. This is not to be used for simple constant definitions. Examples
of its use in the Python documentation include PyObject_HEAD
and
Py_BEGIN_ALLOW_THREADS
.
.. rst:directive:: .. c:type:: name
Describes a C type (whether defined by a typedef or struct). The signature should just be the type name.
Describes a global C variable. The signature should include the type, such as:
.. c:var:: PyObject* PyClass_Type
The following roles create cross-references to C-language constructs if they are defined in the documentation:
.. rst:role:: c:func
Reference a C-language function. Should include trailing parentheses.
The C++ domain (name cpp) supports documenting C++ projects.
The following directives are available:
-
.. cpp:class::
signatures
¶ -
.. cpp:function::
signatures
¶ -
.. cpp:member::
signatures
¶ -
.. cpp:type::
signatures
¶ Describe a C++ object. Full signature specification is supported – give the signature as you would in the declaration. Here some examples:
.. cpp:function:: bool namespaced::theclass::method(int arg1, std::string arg2) Describes a method with parameters and types. .. cpp:function:: bool namespaced::theclass::method(arg1, arg2) Describes a method without types. .. cpp:function:: const T &array<T>::operator[]() const Describes the constant indexing operator of a templated array. .. cpp:function:: operator bool() const Describe a casting operator here. .. cpp:function:: constexpr void foo(std::string &bar[2]) noexcept Describe a constexpr function here. .. cpp:member:: std::string theclass::name .. cpp:member:: std::string theclass::name[N][M] .. cpp:type:: theclass::const_iterator
Will be rendered like this:
-
bool
namespaced::theclass
::
method
(int arg1, std::string arg2)¶ Describes a method with parameters and types.
-
bool
namespaced::theclass
::
method
(arg1, arg2)¶ Describes a method without types.
-
operator bool
() const¶ Describe a casting operator here.
-
constexpr void
foo
(std::string &bar[2]) noexcept¶ Describe a constexpr function here.
-
std::string
theclass
::
name
¶
-
type
theclass
::
const_iterator
¶
-
bool
-
.. cpp:namespace::
namespace
¶ Select the current C++ namespace for the following objects.
-
:cpp:class:
¶ -
:cpp:func:
¶ -
:cpp:member:
¶ -
:cpp:type:
¶ Reference a C++ object. You can give the full signature (and need to, for overloaded functions.)
Note
Sphinx’ syntax to give references a custom title can interfere with linking to template classes, if nothing follows the closing angle bracket, i.e. if the link looks like this:
:cpp:class:`MyClass<T>`
. This is interpreted as a link toT
with a title ofMyClass
. In this case, please escape the opening angle bracket with a backslash, like this::cpp:class:`MyClass\<T>`
.
Note on References
It is currently impossible to link to a specific version of an overloaded method. Currently the C++ domain is the first domain that has basic support for overloaded methods and until there is more data for comparison we don’t want to select a bad syntax to reference a specific overload. Currently Sphinx will link to the first overloaded version of the method / function.