1 [section boost/python/function_doc_signature.hpp]
3 Boost.Python supports docstrings with automatic appending of Pythonic and C++ signatures. This feature is implemented by class `function_doc_signature_generator`. The class uses all of the overloads, supplied arg names and default values, as well as the user-defined docstrings, to generate documentation for a given function.
5 [section Class `function_doc_signature_generator`]
6 The class has only one public function which returns a list of strings documenting the overloads of a function.
8 namespace boost { namespace python { namespace objects {
10 class function_doc_signature_generator
13 static list function_doc_signatures(function const *f);
21 #include <boost/python/module.hpp>
22 #include <boost/python/def.hpp>
23 #include <boost/python/args.hpp>
24 #include <boost/python/tuple.hpp>
25 #include <boost/python/class.hpp>
26 #include <boost/python/overloads.hpp>
27 #include <boost/python/raw_function.hpp>
29 using namespace boost::python;
31 tuple f(int x = 1, double y = 4.25, char const* z = "wow")
33 return make_tuple(x, y, z);
36 BOOST_PYTHON_FUNCTION_OVERLOADS(f_overloads, f, 0, 3)
41 tuple f(int x = 1, double y = 4.25, char const* z = "wow")
43 return make_tuple(x, y, z);
47 BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(X_f_overloads, X::f, 0, 3)
49 tuple raw_func(tuple args, dict kw)
51 return make_tuple(args, kw);
54 BOOST_PYTHON_MODULE(args_ext)
56 def("f", f, (arg("x")=1, arg("y")=4.25, arg("z")="wow")
57 , "This is f's docstring"
60 def("raw", raw_function(raw_func));
62 def("f1", f, f_overloads("f1's docstring", args("x", "y", "z")));
65 class_<X>("X", "This is X's docstring", init<>(args("self")))
67 , "This is X.f's docstring"
68 , args("self","x", "y", "z"))
78 Help on module args_ext:
87 Boost.Python.instance(__builtin__.object)
90 class X(Boost.Python.instance)
91 | This is X's docstring
93 | Method resolution order:
95 | Boost.Python.instance
98 | Methods defined here:
101 | __init__( (object)self) -> None :
103 | void __init__(struct _object *)
106 | f( (X)self, (int)x, (float)y, (str)z) -> tuple : This is X.f's docstring
108 | class boost::python::tuple f(struct X {lvalue},int,double,char const *)
114 f([ (int)x=1 [, (float)y=4.25 [, (str)z='wow']]]) -> tuple : This is f's docstring
116 class boost::python::tuple f([ int=1 [,double=4.25 [,char const *='wow']]])
119 f1([ (int)x [, (float)y [, (str)z]]]) -> tuple : f1's docstring
121 class boost::python::tuple f1([ int [,double [,char const *]]])
124 object raw(tuple args, dict kwds) :
126 object raw(tuple args, dict kwds)