Merge pull request #119 from SylvainCorlay/docstring
Signature formatting for sphinx
diff --git a/example/example11.ref b/example/example11.ref
index 8edc065..54e4fef 100644
--- a/example/example11.ref
+++ b/example/example11.ref
@@ -1,22 +1,22 @@
Help on built-in function kw_func in module example
kkww__ffuunncc(...)
- Signature : (x : int, y : int) -> NoneType
+ kw_func(x : int, y : int) -> NoneType
Help on built-in function kw_func2 in module example
kkww__ffuunncc22(...)
- Signature : (x : int = 100L, y : int = 200L) -> NoneType
+ kw_func2(x : int = 100L, y : int = 200L) -> NoneType
Help on built-in function kw_func3 in module example
kkww__ffuunncc33(...)
- Signature : (data : unicode = u'Hello world!') -> NoneType
+ kw_func3(data : unicode = u'Hello world!') -> NoneType
Help on built-in function kw_func4 in module example
kkww__ffuunncc44(...)
- Signature : (myList : list<int> = [13L, 17L]) -> NoneType
+ kw_func4(myList : list<int> = [13L, 17L]) -> NoneType
kw_func(x=5, y=10)
kw_func(x=5, y=10)
diff --git a/include/pybind11/pybind11.h b/include/pybind11/pybind11.h
index 4cf8ead..a9d5a12 100644
--- a/include/pybind11/pybind11.h
+++ b/include/pybind11/pybind11.h
@@ -295,10 +295,17 @@
int index = 0;
/* Create a nice pydoc rec including all signatures and
docstrings of the functions in the overload chain */
+ if (chain) {
+ // First a generic signature
+ signatures += rec->name;
+ signatures += "(*args, **kwargs)\n";
+ signatures += "Overloaded function.\n\n";
+ }
+ // Then specific overload signatures
for (auto it = chain_start; it != nullptr; it = it->next) {
if (chain)
signatures += std::to_string(++index) + ". ";
- signatures += "Signature : ";
+ signatures += rec->name;
signatures += it->signature;
signatures += "\n";
if (it->doc && strlen(it->doc) > 0) {