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  {
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 
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 
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  {
57 
58  m.def("test_function8", []() {});
59  }
60 
61  {
64 
65  struct DocstringTestFoo {
66  int value;
67  void setValue(int v) { value = v; }
68  int getValue() const { return value; }
69  };
70  py::class_<DocstringTestFoo>(m, "DocstringTestFoo", "This is a class docstring")
71  .def_property("value_prop",
72  &DocstringTestFoo::getValue,
73  &DocstringTestFoo::setValue,
74  "This is a property docstring");
75  }
76 
77  {
78  enum class DocstringTestEnum1 { Member1, Member2 };
79 
80  py::enum_<DocstringTestEnum1>(m, "DocstringTestEnum1", "Enum docstring")
81  .value("Member1", DocstringTestEnum1::Member1)
82  .value("Member2", DocstringTestEnum1::Member2);
83  }
84 
85  {
88 
89  enum class DocstringTestEnum2 { Member1, Member2 };
90 
91  py::enum_<DocstringTestEnum2>(m, "DocstringTestEnum2", "Enum docstring")
92  .value("Member1", DocstringTestEnum2::Member1)
93  .value("Member2", DocstringTestEnum2::Member2);
94  }
95 
96  {
99 
100  enum class DocstringTestEnum3 { Member1, Member2 };
101 
102  py::enum_<DocstringTestEnum3>(m, "DocstringTestEnum3", "Enum docstring")
103  .value("Member1", DocstringTestEnum3::Member1)
104  .value("Member2", DocstringTestEnum3::Member2);
105  }
106 
107  {
110 
111  enum class DocstringTestEnum4 { Member1, Member2 };
112 
113  py::enum_<DocstringTestEnum4>(m, "DocstringTestEnum4", "Enum docstring")
114  .value("Member1", DocstringTestEnum4::Member1)
115  .value("Member2", DocstringTestEnum4::Member2);
116  }
117 
118  {
122 
123  enum class DocstringTestEnum5 { Member1, Member2 };
124 
125  py::enum_<DocstringTestEnum5>(m, "DocstringTestEnum5", "Enum docstring")
126  .value("Member1", DocstringTestEnum5::Member1)
127  .value("Member2", DocstringTestEnum5::Member2);
128  }
129 }
TEST_SUBMODULE
TEST_SUBMODULE(docstring_options, m)
Definition: test_docstring_options.cpp:12
options::disable_function_signatures
options & disable_function_signatures() &
Definition: options.h:40
options::enable_function_signatures
options & enable_function_signatures() &
Definition: options.h:45
m
Matrix3f m
Definition: AngleAxis_mimic_euler.cpp:1
arg
EIGEN_DEVICE_FUNC const EIGEN_STRONG_INLINE ArgReturnType arg() const
Definition: ArrayCwiseUnaryOps.h:66
options::disable_user_defined_docstrings
options & disable_user_defined_docstrings() &
Definition: options.h:30
options
idx_t idx_t idx_t idx_t idx_t idx_t idx_t real_t real_t idx_t * options
Definition: include/metis.h:199
options::enable_enum_members_docstring
options & enable_enum_members_docstring() &
Definition: options.h:55
pybind11_tests.h
v
Array< int, Dynamic, 1 > v
Definition: Array_initializer_list_vector_cxx11.cpp:1
options::disable_enum_members_docstring
options & disable_enum_members_docstring() &
Definition: options.h:50
options
Definition: options.h:16
test_callbacks.value
value
Definition: test_callbacks.py:160


gtsam
Author(s):
autogenerated on Sun Dec 22 2024 04:15:58