test_docstring_options.cpp
Go to the documentation of this file.
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 
12 TEST_SUBMODULE(docstring_options, m) {
13  // test_docstring_options
14  {
16  options.disable_function_signatures();
17 
18  m.def(
19  "test_function1", [](int, int) {}, py::arg("a"), py::arg("b"));
20  m.def(
21  "test_function2", [](int, int) {}, py::arg("a"), py::arg("b"), "A custom docstring");
22 
23  m.def(
24  "test_overloaded1", [](int) {}, py::arg("i"), "Overload docstring");
25  m.def(
26  "test_overloaded1", [](double) {}, py::arg("d"));
27 
28  m.def(
29  "test_overloaded2", [](int) {}, py::arg("i"), "overload docstring 1");
30  m.def(
31  "test_overloaded2", [](double) {}, py::arg("d"), "overload docstring 2");
32 
33  m.def(
34  "test_overloaded3", [](int) {}, py::arg("i"));
35  m.def(
36  "test_overloaded3", [](double) {}, py::arg("d"), "Overload docstr");
37 
38  options.enable_function_signatures();
39 
40  m.def(
41  "test_function3", [](int, int) {}, py::arg("a"), py::arg("b"));
42  m.def(
43  "test_function4", [](int, int) {}, py::arg("a"), py::arg("b"), "A custom docstring");
44 
45  options.disable_function_signatures().disable_user_defined_docstrings();
46 
47  m.def(
48  "test_function5", [](int, int) {}, py::arg("a"), py::arg("b"), "A custom docstring");
49 
50  {
51  py::options nested_options;
52  nested_options.enable_user_defined_docstrings();
53  m.def(
54  "test_function6",
55  [](int, int) {},
56  py::arg("a"),
57  py::arg("b"),
58  "A custom docstring");
59  }
60  }
61 
62  m.def(
63  "test_function7", [](int, int) {}, py::arg("a"), py::arg("b"), "A custom docstring");
64 
65  {
67  options.disable_user_defined_docstrings();
68  options.disable_function_signatures();
69 
70  m.def("test_function8", []() {});
71  }
72 
73  {
75  options.disable_user_defined_docstrings();
76 
77  struct DocstringTestFoo {
78  int value;
79  void setValue(int v) { value = v; }
80  int getValue() const { return value; }
81  };
82  py::class_<DocstringTestFoo>(m, "DocstringTestFoo", "This is a class docstring")
83  .def_property("value_prop",
84  &DocstringTestFoo::getValue,
85  &DocstringTestFoo::setValue,
86  "This is a property docstring");
87  }
88 }
Matrix3f m
idx_t idx_t idx_t idx_t idx_t idx_t idx_t real_t real_t idx_t * options
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const ArgReturnType arg() const
Array< int, Dynamic, 1 > v
TEST_SUBMODULE(docstring_options, m)


gtsam
Author(s):
autogenerated on Tue Jul 4 2023 02:37:45