Skip to content

Commit c9610a9

Browse files
committed
Automatically inserted clang-format off-on around rst blocks (NO manual changes).
1 parent 28e15ec commit c9610a9

File tree

7 files changed

+86
-0
lines changed

7 files changed

+86
-0
lines changed

include/pybind11/attr.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ struct arithmetic { };
7878
/// Mark a function for addition at the beginning of the existing overload chain instead of the end
7979
struct prepend { };
8080

81+
// clang-format off
8182
/** \rst
8283
A call policy which places one or more guard variables (``Ts...``) around the function call.
8384
@@ -96,6 +97,7 @@ struct prepend { };
9697
return foo(args...); // forwarded arguments
9798
});
9899
\endrst */
100+
// clang-format on
99101
template <typename... Ts> struct call_guard;
100102

101103
template <> struct call_guard<> { using type = detail::void_type; };

include/pybind11/cast.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1095,9 +1095,11 @@ arg_v arg::operator=(T &&value) const {
10951095
template <typename /*unused*/> using arg_t = arg_v;
10961096

10971097
inline namespace literals {
1098+
// clang-format off
10981099
/** \rst
10991100
String literal version of `arg`
11001101
\endrst */
1102+
// clang-format on
11011103
constexpr arg operator"" _a(const char *name, size_t) { return arg(name); }
11021104
} // namespace literals
11031105

include/pybind11/detail/common.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,7 @@ extern "C" {
281281
return nullptr; \
282282
} \
283283

284+
// clang-format off
284285
/** \rst
285286
***Deprecated in favor of PYBIND11_MODULE***
286287
@@ -296,6 +297,7 @@ extern "C" {
296297
return m.ptr();
297298
}
298299
\endrst */
300+
// clang-format on
299301
#define PYBIND11_PLUGIN(name) \
300302
PYBIND11_DEPRECATED("PYBIND11_PLUGIN is deprecated, use PYBIND11_MODULE") \
301303
static PyObject *pybind11_init(); \
@@ -308,6 +310,7 @@ extern "C" {
308310
} \
309311
PyObject *pybind11_init()
310312

313+
// clang-format off
311314
/** \rst
312315
This macro creates the entry point that will be invoked when the Python interpreter
313316
imports an extension module. The module name is given as the fist argument and it
@@ -329,6 +332,7 @@ extern "C" {
329332
});
330333
}
331334
\endrst */
335+
// clang-format on
332336
#define PYBIND11_MODULE(name, variable) \
333337
static ::pybind11::module_::module_def \
334338
PYBIND11_CONCAT(pybind11_module_def_, name) PYBIND11_MAYBE_UNUSED; \

include/pybind11/embed.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
}
3131
#endif
3232

33+
// clang-format off
3334
/** \rst
3435
Add a new module to the table of builtins for the interpreter. Must be
3536
defined in global scope. The first macro parameter is the name of the
@@ -45,6 +46,7 @@
4546
});
4647
}
4748
\endrst */
49+
// clang-format on
4850
#define PYBIND11_EMBEDDED_MODULE(name, variable) \
4951
static ::pybind11::module_::module_def \
5052
PYBIND11_CONCAT(pybind11_module_def_, name); \
@@ -87,6 +89,7 @@ struct embedded_module {
8789

8890
PYBIND11_NAMESPACE_END(detail)
8991

92+
// clang-format off
9093
/** \rst
9194
Initialize the Python interpreter. No other pybind11 or CPython API functions can be
9295
called before this is done; with the exception of `PYBIND11_EMBEDDED_MODULE`. The
@@ -100,6 +103,7 @@ PYBIND11_NAMESPACE_END(detail)
100103
101104
.. _Python documentation: https://docs.python.org/3/c-api/init.html#c.Py_InitializeEx
102105
\endrst */
106+
// clang-format on
103107
inline void initialize_interpreter(bool init_signal_handlers = true) {
104108
if (Py_IsInitialized())
105109
pybind11_fail("The interpreter is already running");
@@ -110,6 +114,7 @@ inline void initialize_interpreter(bool init_signal_handlers = true) {
110114
module_::import("sys").attr("path").cast<list>().append(".");
111115
}
112116

117+
// clang-format off
113118
/** \rst
114119
Shut down the Python interpreter. No pybind11 or CPython API functions can be called
115120
after this. In addition, pybind11 objects must not outlive the interpreter:
@@ -145,6 +150,7 @@ inline void initialize_interpreter(bool init_signal_handlers = true) {
145150
freed, either due to reference cycles or user-created global data.
146151
147152
\endrst */
153+
// clang-format on
148154
inline void finalize_interpreter() {
149155
handle builtins(PyEval_GetBuiltins());
150156
const char *id = PYBIND11_INTERNALS_ID;
@@ -165,6 +171,7 @@ inline void finalize_interpreter() {
165171
}
166172
}
167173

174+
// clang-format off
168175
/** \rst
169176
Scope guard version of `initialize_interpreter` and `finalize_interpreter`.
170177
This a move-only guard and only a single instance can exist.
@@ -178,6 +185,7 @@ inline void finalize_interpreter() {
178185
py::print(Hello, World!);
179186
} // <-- interpreter shutdown
180187
\endrst */
188+
// clang-format on
181189
class scoped_interpreter {
182190
public:
183191
scoped_interpreter(bool init_signal_handlers = true) {

include/pybind11/iostream.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ class pythonbuf : public std::streambuf {
140140
PYBIND11_NAMESPACE_END(detail)
141141

142142

143+
// clang-format off
143144
/** \rst
144145
This a move-only guard that redirects output.
145146
@@ -164,6 +165,7 @@ PYBIND11_NAMESPACE_END(detail)
164165
std::cout << "Hello, World!";
165166
}
166167
\endrst */
168+
// clang-format on
167169
class scoped_ostream_redirect {
168170
protected:
169171
std::streambuf *old;
@@ -188,6 +190,7 @@ class scoped_ostream_redirect {
188190
};
189191

190192

193+
// clang-format off
191194
/** \rst
192195
Like `scoped_ostream_redirect`, but redirects cerr by default. This class
193196
is provided primary to make ``py::call_guard`` easier to make.
@@ -199,6 +202,7 @@ class scoped_ostream_redirect {
199202
scoped_estream_redirect>());
200203
201204
\endrst */
205+
// clang-format on
202206
class scoped_estream_redirect : public scoped_ostream_redirect {
203207
public:
204208
scoped_estream_redirect(std::ostream &costream = std::cerr,
@@ -235,6 +239,7 @@ class OstreamRedirect {
235239

236240
PYBIND11_NAMESPACE_END(detail)
237241

242+
// clang-format off
238243
/** \rst
239244
This is a helper function to add a C++ redirect context manager to Python
240245
instead of using a C++ guard. To use it, add the following to your binding code:
@@ -262,6 +267,7 @@ PYBIND11_NAMESPACE_END(detail)
262267
m.noisy_function_with_error_printing()
263268
264269
\endrst */
270+
// clang-format on
265271
inline class_<detail::OstreamRedirect>
266272
add_ostream_redirect(module_ m, const std::string &name = "ostream_redirect") {
267273
return class_<detail::OstreamRedirect>(std::move(m), name.c_str(), module_local())

include/pybind11/pybind11.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -956,11 +956,13 @@ class module_ : public object {
956956
#endif
957957
}
958958

959+
// clang-format off
959960
/** \rst
960961
Create Python binding for a new function within the module scope. ``Func``
961962
can be a plain C++ function, a function pointer, or a lambda function. For
962963
details on the ``Extra&& ... extra`` argument, see section :ref:`extras`.
963964
\endrst */
965+
// clang-format on
964966
template <typename Func, typename... Extra>
965967
module_ &def(const char *name_, Func &&f, const Extra& ... extra) {
966968
cpp_function func(std::forward<Func>(f), name(name_), scope(*this),
@@ -971,6 +973,7 @@ class module_ : public object {
971973
return *this;
972974
}
973975

976+
// clang-format off
974977
/** \rst
975978
Create and return a new Python submodule with the given name and docstring.
976979
This also works recursively, i.e.
@@ -981,6 +984,7 @@ class module_ : public object {
981984
py::module_ m2 = m.def_submodule("sub", "A submodule of 'example'");
982985
py::module_ m3 = m2.def_submodule("subsub", "A submodule of 'example.sub'");
983986
\endrst */
987+
// clang-format on
984988
module_ def_submodule(const char *name, const char *doc = nullptr) {
985989
std::string full_name = std::string(PyModule_GetName(m_ptr))
986990
+ std::string(".") + std::string(name);
@@ -1007,13 +1011,15 @@ class module_ : public object {
10071011
*this = reinterpret_steal<module_>(obj);
10081012
}
10091013

1014+
// clang-format off
10101015
/** \rst
10111016
Adds an object to the module using the given name. Throws if an object with the given name
10121017
already exists.
10131018
10141019
``overwrite`` should almost always be false: attempting to overwrite objects that pybind11 has
10151020
established will, in most cases, break things.
10161021
\endrst */
1022+
// clang-format on
10171023
PYBIND11_NOINLINE void add_object(const char *name, handle obj, bool overwrite = false) {
10181024
if (!overwrite && hasattr(*this, name))
10191025
pybind11_fail("Error during initialization: multiple incompatible definitions with name \"" +
@@ -1028,12 +1034,14 @@ class module_ : public object {
10281034
struct module_def {};
10291035
#endif
10301036

1037+
// clang-format off
10311038
/** \rst
10321039
Create a new top-level module that can be used as the main module of a C extension.
10331040
10341041
For Python 3, ``def`` should point to a statically allocated module_def.
10351042
For Python 2, ``def`` can be a nullptr and is completely ignored.
10361043
\endrst */
1044+
// clang-format on
10371045
static module_ create_extension_module(const char *name, const char *doc, module_def *def) {
10381046
#if PY_MAJOR_VERSION >= 3
10391047
// module_def is PyModuleDef
@@ -2173,6 +2181,7 @@ inline function get_type_override(const void *this_ptr, const type_info *this_ty
21732181
}
21742182
PYBIND11_NAMESPACE_END(detail)
21752183

2184+
// clang-format off
21762185
/** \rst
21772186
Try to retrieve a python method by the provided name from the instance pointed to by the this_ptr.
21782187
@@ -2181,6 +2190,7 @@ PYBIND11_NAMESPACE_END(detail)
21812190
:name: The name of the overridden Python method to retrieve.
21822191
:return: The Python method by this name from the object or an empty function wrapper.
21832192
\endrst */
2193+
// clang-format on
21842194
template <class T> function get_override(const T *this_ptr, const char *name) {
21852195
auto tinfo = detail::get_type_info(typeid(T));
21862196
return tinfo ? detail::get_type_override(this_ptr, tinfo, name) : function();
@@ -2201,6 +2211,7 @@ template <class T> function get_override(const T *this_ptr, const char *name) {
22012211
} \
22022212
} while (false)
22032213

2214+
// clang-format off
22042215
/** \rst
22052216
Macro to populate the virtual method in the trampoline class. This macro tries to look up a method named 'fn'
22062217
from the Python side, deals with the :ref:`gil` and necessary argument conversions to call this method and return
@@ -2218,22 +2229,26 @@ template <class T> function get_override(const T *this_ptr, const char *name) {
22182229
);
22192230
}
22202231
\endrst */
2232+
// clang-format on
22212233
#define PYBIND11_OVERRIDE_NAME(ret_type, cname, name, fn, ...) \
22222234
do { \
22232235
PYBIND11_OVERRIDE_IMPL(PYBIND11_TYPE(ret_type), PYBIND11_TYPE(cname), name, __VA_ARGS__); \
22242236
return cname::fn(__VA_ARGS__); \
22252237
} while (false)
22262238

2239+
// clang-format off
22272240
/** \rst
22282241
Macro for pure virtual functions, this function is identical to :c:macro:`PYBIND11_OVERRIDE_NAME`, except that it
22292242
throws if no override can be found.
22302243
\endrst */
2244+
// clang-format on
22312245
#define PYBIND11_OVERRIDE_PURE_NAME(ret_type, cname, name, fn, ...) \
22322246
do { \
22332247
PYBIND11_OVERRIDE_IMPL(PYBIND11_TYPE(ret_type), PYBIND11_TYPE(cname), name, __VA_ARGS__); \
22342248
pybind11::pybind11_fail("Tried to call pure virtual function \"" PYBIND11_STRINGIFY(cname) "::" name "\""); \
22352249
} while (false)
22362250

2251+
// clang-format off
22372252
/** \rst
22382253
Macro to populate the virtual method in the trampoline class. This macro tries to look up the method
22392254
from the Python side, deals with the :ref:`gil` and necessary argument conversions to call this method and return
@@ -2258,13 +2273,16 @@ template <class T> function get_override(const T *this_ptr, const char *name) {
22582273
}
22592274
};
22602275
\endrst */
2276+
// clang-format on
22612277
#define PYBIND11_OVERRIDE(ret_type, cname, fn, ...) \
22622278
PYBIND11_OVERRIDE_NAME(PYBIND11_TYPE(ret_type), PYBIND11_TYPE(cname), #fn, fn, __VA_ARGS__)
22632279

2280+
// clang-format off
22642281
/** \rst
22652282
Macro for pure virtual functions, this function is identical to :c:macro:`PYBIND11_OVERRIDE`, except that it throws
22662283
if no override can be found.
22672284
\endrst */
2285+
// clang-format on
22682286
#define PYBIND11_OVERRIDE_PURE(ret_type, cname, fn, ...) \
22692287
PYBIND11_OVERRIDE_PURE_NAME(PYBIND11_TYPE(ret_type), PYBIND11_TYPE(cname), #fn, fn, __VA_ARGS__)
22702288

0 commit comments

Comments
 (0)