Modify

Opened 10 years ago

Last modified 8 years ago

#1180 new Feature Requests

[boost.python] def_readwrite need a default docstring

Reported by: qiaozhiqiang@… Owned by: troy d. straszheim
Milestone: To Be Determined Component: python USE GITHUB
Version: Boost 1.34.0 Severity: Problem
Keywords: def_readwrite docstring Cc: rwgk@…

Description (last modified by Dave Abrahams)

the default docstring defined by def_readwrite is null, can boost.python add the type name of my_s::a as the default docstring? like the function's "C++ signature" docstring.

struct my_s
{
        int a;
};

void export_module
{
      class_<my_s >  s_class("my_s", init<  >());
      s_class.def_readwrite("a", &my_s::a);// __doc__ is empty, can boost.python add the type name of my_s::a as the default docstring? like the function's "C++ signature" docstring.
}

// I do this like this:
// get type name of data member of class 
template<typename T, typename C>
char const* MemberTypeName(T C::*)
{
        char const* name = typeid(T).name();
        return name;
}

// boost::python def_readwrite no docstring
// read write property
#define DEF_READWRITE(n, p) \
        def_readwrite((n), (p), std::string("read write property, type is ") + MemberTypeName(p)).c_str())



void export_module
{
      class_<my_s >  s_class("my_s", init<  >());
      s_class.DEF_READWRITE("a", &my_s::a);// replace all auto genarated def_readwrite to DEF_READWRITE.
}

Attachments (0)

Change History (4)

comment:1 Changed 9 years ago by Dave Abrahams

Description: modified (diff)

Fix formatting mess.

comment:2 Changed 9 years ago by Dave Abrahams

Cc: rwgk@… added
Status: newassigned

Not sure if this makes sense. Ralf, what do you think?

comment:3 in reply to:  2 Changed 9 years ago by Ralf W. Grosse-Kunstleve

Replying to dave:

Not sure if this makes sense. Ralf, what do you think?

I'm having trouble making sense of this, too. In Python:

s = my_s() print s.a # that's a plain Python int print s.a.doc # Python int doc

What would be the Python syntax to get to the C++ doc?

comment:4 Changed 8 years ago by troy d. straszheim

Owner: changed from Dave Abrahams to troy d. straszheim
Status: assignednew

Here's the difference between one documented and one undocumented property from the properties test (1.40.0):

help(properties_ext.X.value_r)

Help on property:

help(proeprties_ext.X.value_r_ds)

Help on property:

value_r_ds is read-only

Modify Ticket

Change Properties
Set your email in Preferences
Action
as new The owner will remain troy d. straszheim.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.