GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Emit qualfied names in docstrings · boostorg/python@7a3cc07

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • include/boost/python/object
    • function_doc_signature.hpp
  • src/object
    • function_doc_signature.cpp
  • test
    • nested.cpp
    • nested.py
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎include/boost/python/object/function_doc_signature.hpp‎

Copy file name to clipboardExpand all lines: include/boost/python/object/function_doc_signature.hpp
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
namespace boost { namespace python { namespace objects {
1919

2020
class function_doc_signature_generator{
21-
static const char * py_type_str(const python::detail::signature_element &s);
21+
static str py_type_str(const python::detail::signature_element &s);
2222
static bool arity_cmp( function const *f1, function const *f2 );
2323
static bool are_seq_overloads( function const *f1, function const *f2 , bool check_docs);
2424
static std::vector<function const*> flatten(function const *f);
Collapse file

‎src/object/function_doc_signature.cpp‎

Copy file name to clipboardExpand all lines: src/object/function_doc_signature.cpp
+9-4Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,19 +114,24 @@ namespace boost { namespace python { namespace objects {
114114
return res;
115115
}
116116

117-
const char * function_doc_signature_generator::py_type_str(const python::detail::signature_element &s)
117+
str function_doc_signature_generator::py_type_str(const python::detail::signature_element &s)
118118
{
119119
if (s.basename==std::string("void")){
120120
static const char * none = "None";
121-
return none;
121+
return str(none);
122122
}
123123

124124
PyTypeObject const * py_type = s.pytype_f?s.pytype_f():0;
125+
#if PY_VERSION_HEX < 0x03030000
125126
if ( py_type )
126-
return py_type->tp_name;
127+
return str(py_type->tp_name);
128+
#else
129+
if ( py_type && (py_type->tp_flags & Py_TPFLAGS_HEAPTYPE) )
130+
return str(handle<>(borrowed(((PyHeapTypeObject*)(py_type))->ht_qualname)));
131+
#endif
127132
else{
128133
static const char * object = "object";
129-
return object;
134+
return str(object);
130135
}
131136
}
132137

Collapse file

‎test/nested.cpp‎

Copy file name to clipboardExpand all lines: test/nested.cpp
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
// http://www.boost.org/LICENSE_1_0.txt)
55
#include <boost/python/module.hpp>
66
#include <boost/python/class.hpp>
7+
#include <boost/python/def.hpp>
78
#include <boost/python/operators.hpp>
89
#include <boost/python/scope.hpp>
910
#include "test_class.hpp"
@@ -26,11 +27,13 @@ std::ostream& operator<<(std::ostream& s, Y const& x)
2627
return s << x.value();
2728
}
2829

30+
void test_function(const X& x, const Y& y) {}
2931

3032
BOOST_PYTHON_MODULE(nested_ext)
3133
{
3234
using namespace boost::python;
3335

36+
{
3437
// Establish X as the current scope.
3538
scope x_class
3639
= class_<X>("X", init<int>())
@@ -42,6 +45,10 @@ BOOST_PYTHON_MODULE(nested_ext)
4245
class_<Y>("Y", init<int>())
4346
.def(str(self))
4447
;
48+
}
49+
50+
// The generated docstring will use the fully-qualified name of Y
51+
def("test_function", &test_function);
4552
}
4653

4754

Collapse file

‎test/nested.py‎

Copy file name to clipboardExpand all lines: test/nested.py
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
2222
>>> X.Y.__name__
2323
'Y'
24+
25+
>>> test_function.__doc__.strip().split('\\n')[0]
26+
'test_function( (X)arg1, (X.Y)arg2) -> None :'
2427
2528
'''
2629

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.