1/*
2    tests/test_docstring_options.cpp -- generation of docstrings and signatures
3
4    Copyright (c) 2016 Wenzel Jakob <wenzel.jakob@epfl.ch>
5
6    All rights reserved. Use of this source code is governed by a
7    BSD-style license that can be found in the LICENSE file.
8*/
9
10#include "pybind11_tests.h"
11
12TEST_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("test_function6", [](int, int) {}, py::arg("a"), py::arg("b"), "A custom docstring");
43        }
44    }
45
46    m.def("test_function7", [](int, int) {}, py::arg("a"), py::arg("b"), "A custom docstring");
47
48    {
49        py::options options;
50        options.disable_user_defined_docstrings();
51
52        struct DocstringTestFoo {
53            int value;
54            void setValue(int v) { value = v; }
55            int getValue() const { return value; }
56        };
57        py::class_<DocstringTestFoo>(m, "DocstringTestFoo", "This is a class docstring")
58            .def_property("value_prop", &DocstringTestFoo::getValue, &DocstringTestFoo::setValue, "This is a property docstring")
59        ;
60    }
61}
62