Skip to content

Commit

Permalink
Manual rst-endrst fixups, based on rwgk/pybind11_scons@fa4ffb4
Browse files Browse the repository at this point in the history
  • Loading branch information
Ralf W. Grosse-Kunstleve committed Feb 5, 2022
1 parent e379d5d commit 60b7eb4
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 20 deletions.
4 changes: 2 additions & 2 deletions include/pybind11/iostream.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ PYBIND11_NAMESPACE_END(detail)
.. code-block:: cpp
{
py::scoped_ostream_redirect output{std::cerr,
py::module::import("sys").attr("stderr")}; std::cout << "Hello, World!";
py::scoped_ostream_redirect output{std::cerr, py::module::import("sys").attr("stderr")};
std::cout << "Hello, World!";
}
\endrst */
class scoped_ostream_redirect {
Expand Down
32 changes: 18 additions & 14 deletions include/pybind11/pybind11.h
Original file line number Diff line number Diff line change
Expand Up @@ -1166,7 +1166,8 @@ class module_ : public object {
already exists.
``overwrite`` should almost always be false: attempting to overwrite objects that pybind11
has established will, in most cases, break things. \endrst */
has established will, in most cases, break things.
\endrst */
PYBIND11_NOINLINE void add_object(const char *name, handle obj, bool overwrite = false) {
if (!overwrite && hasattr(*this, name))
pybind11_fail(
Expand Down Expand Up @@ -2657,12 +2658,13 @@ PYBIND11_NAMESPACE_END(detail)

/** \rst
Try to retrieve a python method by the provided name from the instance pointed to by the
this_ptr.
this_ptr.
:this_ptr: The pointer to the object the overridden method should be retrieved for. This should
be the first non-trampoline class encountered in the inheritance chain. :name: The name of the
overridden Python method to retrieve. :return: The Python method by this name from the object or
an empty function wrapper. \endrst */
be the first non-trampoline class encountered in the inheritance chain.
:name: The name of the overridden Python method to retrieve.
:return: The Python method by this name from the object or an empty function wrapper.
\endrst */
template <class T>
function get_override(const T *this_ptr, const char *name) {
auto *tinfo = detail::get_type_info(typeid(T));
Expand All @@ -2686,10 +2688,10 @@ function get_override(const T *this_ptr, const char *name) {

/** \rst
Macro to populate the virtual method in the trampoline class. This macro tries to look up a
method named 'fn' from the Python side, deals with the :ref:`gil` and necessary argument
conversions to call this method and return the appropriate type. See :ref:`overriding_virtuals` for
more information. This macro should be used when the method name in C is not the same as the method
name in Python. For example with `__str__`.
method named 'fn' from the Python side, deals with the :ref:`gil` and necessary argument
conversions to call this method and return the appropriate type.
See :ref:`overriding_virtuals` for more information. This macro should be used when the method
name in C is not the same as the method name in Python. For example with `__str__`.
.. code-block:: cpp
Expand All @@ -2710,7 +2712,8 @@ name in Python. For example with `__str__`.

/** \rst
Macro for pure virtual functions, this function is identical to
:c:macro:`PYBIND11_OVERRIDE_NAME`, except that it throws if no override can be found. \endrst */
:c:macro:`PYBIND11_OVERRIDE_NAME`, except that it throws if no override can be found.
\endrst */
#define PYBIND11_OVERRIDE_PURE_NAME(ret_type, cname, name, fn, ...) \
do { \
PYBIND11_OVERRIDE_IMPL(PYBIND11_TYPE(ret_type), PYBIND11_TYPE(cname), name, __VA_ARGS__); \
Expand All @@ -2720,9 +2723,9 @@ name in Python. For example with `__str__`.

/** \rst
Macro to populate the virtual method in the trampoline class. This macro tries to look up the
method from the Python side, deals with the :ref:`gil` and necessary argument conversions to call
this method and return the appropriate type. This macro should be used if the method name in C and
in Python are identical. See :ref:`overriding_virtuals` for more information.
method from the Python side, deals with the :ref:`gil` and necessary argument conversions to
call this method and return the appropriate type. This macro should be used if the method name
in C and in Python are identical. See :ref:`overriding_virtuals` for more information.
.. code-block:: cpp
Expand All @@ -2747,7 +2750,8 @@ in Python are identical. See :ref:`overriding_virtuals` for more information.

/** \rst
Macro for pure virtual functions, this function is identical to :c:macro:`PYBIND11_OVERRIDE`,
except that it throws if no override can be found. \endrst */
except that it throws if no override can be found.
\endrst */
#define PYBIND11_OVERRIDE_PURE(ret_type, cname, fn, ...) \
PYBIND11_OVERRIDE_PURE_NAME( \
PYBIND11_TYPE(ret_type), PYBIND11_TYPE(cname), #fn, fn, __VA_ARGS__)
Expand Down
6 changes: 2 additions & 4 deletions include/pybind11/pytypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -1832,8 +1832,7 @@ class memoryview : public object {
See also: Python C API documentation for `PyMemoryView_FromBuffer`_.
.. _PyMemoryView_FromBuffer:
https://docs.python.org/c-api/memoryview.html#c.PyMemoryView_FromBuffer
.. _PyMemoryView_FromBuffer: https://docs.python.org/c-api/memoryview.html#c.PyMemoryView_FromBuffer
:param ptr: Pointer to the buffer.
:param itemsize: Byte size of an element.
Expand Down Expand Up @@ -1894,8 +1893,7 @@ class memoryview : public object {
See also: Python C API documentation for `PyMemoryView_FromBuffer`_.
.. _PyMemoryView_FromMemory:
https://docs.python.org/c-api/memoryview.html#c.PyMemoryView_FromMemory \endrst */
.. _PyMemoryView_FromMemory: https://docs.python.org/c-api/memoryview.html#c.PyMemoryView_FromMemory \endrst */
static memoryview from_memory(void *mem, ssize_t size, bool readonly = false) {
PyObject *ptr = PyMemoryView_FromMemory(
reinterpret_cast<char *>(mem), size, (readonly) ? PyBUF_READ : PyBUF_WRITE);
Expand Down

0 comments on commit 60b7eb4

Please sign in to comment.