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

Add generated docstrings to property fget/fset

This commit is contained in:
Jakob van Santen
2023-04-27 09:52:03 +02:00
committed by Stefan Seefeld
parent d1910f3d65
commit 4c6f40fb82
6 changed files with 63 additions and 22 deletions

View File

@@ -419,6 +419,30 @@ namespace detail
extern char cpp_signature_tag[];
}
object const& function::add_doc(object const& attribute, char const* doc)
{
str _doc;
if (docstring_options::show_py_signatures_)
{
_doc += str(const_cast<const char*>(detail::py_signature_tag));
}
if (doc != 0 && docstring_options::show_user_defined_)
_doc += doc;
if (docstring_options::show_cpp_signatures_)
{
_doc += str(const_cast<const char*>(detail::cpp_signature_tag));
}
if(_doc)
{
object mutable_attribute(attribute);
mutable_attribute.attr("__doc__")= _doc;
}
return attribute;
}
void function::add_to_namespace(
object const& name_space, char const* name_, object const& attribute, char const* doc)
{
@@ -545,24 +569,7 @@ void function::add_to_namespace(
"C++ signature:", f->signature(true)));
}
*/
str _doc;
if (docstring_options::show_py_signatures_)
{
_doc += str(const_cast<const char*>(detail::py_signature_tag));
}
if (doc != 0 && docstring_options::show_user_defined_)
_doc += doc;
if (docstring_options::show_cpp_signatures_)
{
_doc += str(const_cast<const char*>(detail::cpp_signature_tag));
}
if(_doc)
{
object mutable_attribute(attribute);
mutable_attribute.attr("__doc__")= _doc;
}
add_doc(attribute, doc);
}
BOOST_PYTHON_DECL void add_to_namespace(
@@ -577,6 +584,11 @@ BOOST_PYTHON_DECL void add_to_namespace(
function::add_to_namespace(name_space, name, attribute, doc);
}
BOOST_PYTHON_DECL object const& add_doc(object const& attribute, char const* doc)
{
return function::add_doc(attribute, doc);
}
namespace
{