|
Packit |
534379 |
/*
|
|
Packit |
534379 |
tests/test_docstring_options.cpp -- generation of docstrings and signatures
|
|
Packit |
534379 |
|
|
Packit |
534379 |
Copyright (c) 2016 Wenzel Jakob <wenzel.jakob@epfl.ch>
|
|
Packit |
534379 |
|
|
Packit |
534379 |
All rights reserved. Use of this source code is governed by a
|
|
Packit |
534379 |
BSD-style license that can be found in the LICENSE file.
|
|
Packit |
534379 |
*/
|
|
Packit |
534379 |
|
|
Packit |
534379 |
#include "pybind11_tests.h"
|
|
Packit |
534379 |
|
|
Packit |
534379 |
TEST_SUBMODULE(docstring_options, m) {
|
|
Packit |
534379 |
// test_docstring_options
|
|
Packit |
534379 |
{
|
|
Packit |
534379 |
py::options options;
|
|
Packit |
534379 |
options.disable_function_signatures();
|
|
Packit |
534379 |
|
|
Packit |
534379 |
m.def("test_function1", [](int, int) {}, py::arg("a"), py::arg("b"));
|
|
Packit |
534379 |
m.def("test_function2", [](int, int) {}, py::arg("a"), py::arg("b"), "A custom docstring");
|
|
Packit |
534379 |
|
|
Packit |
534379 |
m.def("test_overloaded1", [](int) {}, py::arg("i"), "Overload docstring");
|
|
Packit |
534379 |
m.def("test_overloaded1", [](double) {}, py::arg("d"));
|
|
Packit |
534379 |
|
|
Packit |
534379 |
m.def("test_overloaded2", [](int) {}, py::arg("i"), "overload docstring 1");
|
|
Packit |
534379 |
m.def("test_overloaded2", [](double) {}, py::arg("d"), "overload docstring 2");
|
|
Packit |
534379 |
|
|
Packit |
534379 |
m.def("test_overloaded3", [](int) {}, py::arg("i"));
|
|
Packit |
534379 |
m.def("test_overloaded3", [](double) {}, py::arg("d"), "Overload docstr");
|
|
Packit |
534379 |
|
|
Packit |
534379 |
options.enable_function_signatures();
|
|
Packit |
534379 |
|
|
Packit |
534379 |
m.def("test_function3", [](int, int) {}, py::arg("a"), py::arg("b"));
|
|
Packit |
534379 |
m.def("test_function4", [](int, int) {}, py::arg("a"), py::arg("b"), "A custom docstring");
|
|
Packit |
534379 |
|
|
Packit |
534379 |
options.disable_function_signatures().disable_user_defined_docstrings();
|
|
Packit |
534379 |
|
|
Packit |
534379 |
m.def("test_function5", [](int, int) {}, py::arg("a"), py::arg("b"), "A custom docstring");
|
|
Packit |
534379 |
|
|
Packit |
534379 |
{
|
|
Packit |
534379 |
py::options nested_options;
|
|
Packit |
534379 |
nested_options.enable_user_defined_docstrings();
|
|
Packit |
534379 |
m.def("test_function6", [](int, int) {}, py::arg("a"), py::arg("b"), "A custom docstring");
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
|
|
Packit |
534379 |
m.def("test_function7", [](int, int) {}, py::arg("a"), py::arg("b"), "A custom docstring");
|
|
Packit |
534379 |
|
|
Packit |
534379 |
{
|
|
Packit |
534379 |
py::options options;
|
|
Packit |
534379 |
options.disable_user_defined_docstrings();
|
|
Packit |
534379 |
|
|
Packit |
534379 |
struct DocstringTestFoo {
|
|
Packit |
534379 |
int value;
|
|
Packit |
534379 |
void setValue(int v) { value = v; }
|
|
Packit |
534379 |
int getValue() const { return value; }
|
|
Packit |
534379 |
};
|
|
Packit |
534379 |
py::class_<DocstringTestFoo>(m, "DocstringTestFoo", "This is a class docstring")
|
|
Packit |
534379 |
.def_property("value_prop", &DocstringTestFoo::getValue, &DocstringTestFoo::setValue, "This is a property docstring")
|
|
Packit |
534379 |
;
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
}
|