@@ -419,6 +419,30 @@ namespace detail
419419 extern char cpp_signature_tag[];
420420}
421421
422+ object const & function::add_doc (object const & attribute, char const * doc)
423+ {
424+ str _doc;
425+
426+ if (docstring_options::show_py_signatures_)
427+ {
428+ _doc += str (const_cast <const char *>(detail::py_signature_tag));
429+ }
430+ if (doc != 0 && docstring_options::show_user_defined_)
431+ _doc += doc;
432+
433+ if (docstring_options::show_cpp_signatures_)
434+ {
435+ _doc += str (const_cast <const char *>(detail::cpp_signature_tag));
436+ }
437+ if (_doc)
438+ {
439+ object mutable_attribute (attribute);
440+ mutable_attribute.attr (" __doc__" )= _doc;
441+ }
442+
443+ return attribute;
444+ }
445+
422446void function::add_to_namespace (
423447 object const & name_space, char const * name_, object const & attribute, char const * doc)
424448{
@@ -545,24 +569,7 @@ void function::add_to_namespace(
545569 "C++ signature:", f->signature(true)));
546570 }
547571 */
548- str _doc;
549-
550- if (docstring_options::show_py_signatures_)
551- {
552- _doc += str (const_cast <const char *>(detail::py_signature_tag));
553- }
554- if (doc != 0 && docstring_options::show_user_defined_)
555- _doc += doc;
556-
557- if (docstring_options::show_cpp_signatures_)
558- {
559- _doc += str (const_cast <const char *>(detail::cpp_signature_tag));
560- }
561- if (_doc)
562- {
563- object mutable_attribute (attribute);
564- mutable_attribute.attr (" __doc__" )= _doc;
565- }
572+ add_doc (attribute, doc);
566573}
567574
568575BOOST_PYTHON_DECL void add_to_namespace (
@@ -577,6 +584,11 @@ BOOST_PYTHON_DECL void add_to_namespace(
577584 function::add_to_namespace (name_space, name, attribute, doc);
578585}
579586
587+ BOOST_PYTHON_DECL object const & add_doc (object const & attribute, char const * doc)
588+ {
589+ return function::add_doc (attribute, doc);
590+ }
591+
580592
581593namespace
582594{
0 commit comments