From 60b7eb410fefe2b23aeb6906f2a9184e91b11a15 Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Fri, 4 Feb 2022 16:17:52 -0800 Subject: [PATCH] Manual rst-endrst fixups, based on https://github.com/rwgk/pybind11_scons/commit/fa4ffb49c325430d2f36084a2e98f495a3ef7c2c --- include/pybind11/iostream.h | 4 ++-- include/pybind11/pybind11.h | 32 ++++++++++++++++++-------------- include/pybind11/pytypes.h | 6 ++---- 3 files changed, 22 insertions(+), 20 deletions(-) diff --git a/include/pybind11/iostream.h b/include/pybind11/iostream.h index 2bc910de5d..86469b803b 100644 --- a/include/pybind11/iostream.h +++ b/include/pybind11/iostream.h @@ -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 { diff --git a/include/pybind11/pybind11.h b/include/pybind11/pybind11.h index 89a0c6bf40..ab8c71fca7 100644 --- a/include/pybind11/pybind11.h +++ b/include/pybind11/pybind11.h @@ -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( @@ -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 function get_override(const T *this_ptr, const char *name) { auto *tinfo = detail::get_type_info(typeid(T)); @@ -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 @@ -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__); \ @@ -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 @@ -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__) diff --git a/include/pybind11/pytypes.h b/include/pybind11/pytypes.h index 53a60b9f78..0541ed4ac7 100644 --- a/include/pybind11/pytypes.h +++ b/include/pybind11/pytypes.h @@ -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. @@ -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(mem), size, (readonly) ? PyBUF_READ : PyBUF_WRITE);