diff --git a/doc/v2/class.html b/doc/v2/class.html
index 5505dc5c..79ff4bd8 100644
--- a/doc/v2/class.html
+++ b/doc/v2/class.html
@@ -462,7 +462,9 @@ class_& def(char const* name, Fn fn, A1 const& a1, A2 const& a2, A3
Any ntbs. |
Value will be bound to the __doc__ attribute
- of the resulting method overload. |
+ of the resulting method overload. If an earlier overload
+ supplied a docstring, two newline characters and the new
+ docstring are appended to it.
diff --git a/src/object/function.cpp b/src/object/function.cpp
index 675b4002..b7139fba 100644
--- a/src/object/function.cpp
+++ b/src/object/function.cpp
@@ -472,7 +472,12 @@ void function::add_to_namespace(
if (doc != 0)
{
object attr_copy(attribute);
- attr_copy.attr("__doc__") = doc;
+ if (PyObject_HasAttrString(attr_copy.ptr(), "__doc__") && attr_copy.attr("__doc__")) {
+ attr_copy.attr("__doc__") += "\n\n";
+ attr_copy.attr("__doc__") += doc;
+ }
+ else
+ attr_copy.attr("__doc__") = doc;
}
}
diff --git a/test/docstring.cpp b/test/docstring.cpp
index 604a4947..ddd1ee8a 100644
--- a/test/docstring.cpp
+++ b/test/docstring.cpp
@@ -47,6 +47,8 @@ BOOST_PYTHON_MODULE(docstring_ext)
)
.def("value", &X::value,
"gets the value of the object")
+ .def( "value", &X::value,
+ "also gets the value of the object")
;
def("create", create, return_value_policy(),
diff --git a/test/docstring.py b/test/docstring.py
index c154adb7..17456950 100644
--- a/test/docstring.py
+++ b/test/docstring.py
@@ -15,9 +15,6 @@ includes some error-checking
this is the __init__ function
its documentation has two lines.
->>> printdoc(X.value)
-gets the value of the object
-
>>> printdoc(create)
creates a new X object
@@ -25,6 +22,13 @@ creates a new X object
compute the factorial
'''
+def check_double_string():
+ """
+ >>> assert check_double_string() == True
+ """
+ from docstring_ext import X
+ return X.value.__doc__ == "gets the value of the object\n\nalso gets the value of the object"
+
def run(args = None):
import sys
import doctest