2
0
mirror of https://github.com/boostorg/python.git synced 2026-01-24 06:02:14 +00:00

Concatentation subsequent function docstrings rather than replace the original.

[SVN r27332]
This commit is contained in:
Jonathan Brandmeyer
2005-02-11 20:03:13 +00:00
parent 1cfa79554d
commit 4d50bf0ad9
4 changed files with 18 additions and 5 deletions

View File

@@ -462,7 +462,9 @@ class_& def(char const* name, Fn fn, A1 const& a1, A2 const& a2, A3
<td>Any <a href="definitions.html#ntbs">ntbs</a>.</td>
<td>Value will be bound to the <code>__doc__</code> attribute
of the resulting method overload.</td>
of the resulting method overload. If an earlier overload
supplied a docstring, two newline characters and the new
docstring are appended to it.</td>
</tr>
<tr>

View File

@@ -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;
}
}

View File

@@ -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<manage_new_object>(),

View File

@@ -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