cppyabm
1.0.17
An agent-based library to integrate C++ and Python
examples
Cppy
build
_deps
pybind11-src
tests
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
{
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
options
.
disable_function_signatures
();
52
53
m
.def(
"test_function8"
, []() {});
54
}
55
56
{
57
py::options
options
;
58
options
.
disable_user_defined_docstrings
();
59
60
struct
DocstringTestFoo {
61
int
value
;
62
void
setValue(
int
v) {
value
= v; }
63
int
getValue()
const
{
return
value
; }
64
};
65
py::class_<DocstringTestFoo>(
m
,
"DocstringTestFoo"
,
"This is a class docstring"
)
66
.def_property(
"value_prop"
, &DocstringTestFoo::getValue, &DocstringTestFoo::setValue,
"This is a property docstring"
)
67
;
68
}
69
}
TEST_SUBMODULE
TEST_SUBMODULE(docstring_options, m)
Definition:
test_docstring_options.cpp:12
options::disable_function_signatures
options & disable_function_signatures() &
Definition:
options.h:37
options::enable_function_signatures
options & enable_function_signatures() &
Definition:
options.h:39
options::disable_user_defined_docstrings
options & disable_user_defined_docstrings() &
Definition:
options.h:33
pybind11_tests.h
test_async.m
m
Definition:
test_async.py:5
options
Definition:
options.h:16
test_callbacks.value
value
Definition:
test_callbacks.py:126
Generated by
1.8.19