mirror of
https://github.com/pybind/pybind11.git
synced 2026-04-19 22:39:09 +00:00
Fix extra docstring newlines under options.disable_function_signatures()
When using pybind::options to disable function signatures, user-defined docstrings only get appended if they exist, but newlines were getting appended unconditionally, so the docstring could end up with blank lines (depending on which overloads, in particular, provided docstrings). This commit suppresses the empty lines by only adding newlines for overloads when needed.
This commit is contained in:
@@ -24,6 +24,15 @@ test_initializer docstring_generation([](py::module &m) {
|
||||
m.def("test_function1", [](int, int) {}, py::arg("a"), py::arg("b"));
|
||||
m.def("test_function2", [](int, int) {}, py::arg("a"), py::arg("b"), "A custom docstring");
|
||||
|
||||
m.def("test_overloaded1", [](int) {}, py::arg("i"), "Overload docstring");
|
||||
m.def("test_overloaded1", [](double) {}, py::arg("d"));
|
||||
|
||||
m.def("test_overloaded2", [](int) {}, py::arg("i"), "overload docstring 1");
|
||||
m.def("test_overloaded2", [](double) {}, py::arg("d"), "overload docstring 2");
|
||||
|
||||
m.def("test_overloaded3", [](int) {}, py::arg("i"));
|
||||
m.def("test_overloaded3", [](double) {}, py::arg("d"), "Overload docstr");
|
||||
|
||||
options.enable_function_signatures();
|
||||
|
||||
m.def("test_function3", [](int, int) {}, py::arg("a"), py::arg("b"));
|
||||
|
||||
Reference in New Issue
Block a user