| 10 | #include "pybind11_tests.h" |
| 11 | |
| 12 | TEST_SUBMODULE(docstring_options, m) { |
| 13 | // test_docstring_options |
| 14 | { |
| 15 | py::options options; |
| 16 | options.disable_function_signatures(); |
| 17 | |
| 18 | m.def("test_function1", [](int, int) {}, py::arg("a"), py::arg("b")); |
| 19 | m.def("test_function2", [](int, int) {}, py::arg("a"), py::arg("b"), "A custom docstring"); |
| 20 | |
| 21 | m.def("test_overloaded1", [](int) {}, py::arg("i"), "Overload docstring"); |
| 22 | m.def("test_overloaded1", [](double) {}, py::arg("d")); |
| 23 | |
| 24 | m.def("test_overloaded2", [](int) {}, py::arg("i"), "overload docstring 1"); |
| 25 | m.def("test_overloaded2", [](double) {}, py::arg("d"), "overload docstring 2"); |
| 26 | |
| 27 | m.def("test_overloaded3", [](int) {}, py::arg("i")); |
| 28 | m.def("test_overloaded3", [](double) {}, py::arg("d"), "Overload docstr"); |
| 29 | |
| 30 | options.enable_function_signatures(); |
| 31 | |
| 32 | m.def("test_function3", [](int, int) {}, py::arg("a"), py::arg("b")); |
| 33 | m.def("test_function4", [](int, int) {}, py::arg("a"), py::arg("b"), "A custom docstring"); |
| 34 | |
| 35 | options.disable_function_signatures().disable_user_defined_docstrings(); |
| 36 | |
| 37 | m.def("test_function5", [](int, int) {}, py::arg("a"), py::arg("b"), "A custom docstring"); |
| 38 | |
| 39 | { |
| 40 | py::options nested_options; |
| 41 | nested_options.enable_user_defined_docstrings(); |
| 42 | m.def( |
| 43 | "test_function6", |
| 44 | [](int, int) {}, |
| 45 | py::arg("a"), |
| 46 | py::arg("b"), |
| 47 | "A custom docstring"); |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | m.def("test_function7", [](int, int) {}, py::arg("a"), py::arg("b"), "A custom docstring"); |
| 52 | |
| 53 | { |
| 54 | py::options options; |
| 55 | options.disable_user_defined_docstrings(); |
| 56 | options.disable_function_signatures(); |
| 57 | |
| 58 | m.def("test_function8", []() {}); |
| 59 | } |
| 60 | |
| 61 | { |
| 62 | py::options options; |
| 63 | options.disable_user_defined_docstrings(); |
| 64 | |
| 65 | struct DocstringTestFoo { |
| 66 | int value; |
| 67 | void setValue(int v) { value = v; } |
| 68 | int getValue() const { return value; } |
| 69 | }; |