Boost C++ Libraries: Ticket #1180: [boost.python] def_readwrite need a default docstring https://svn.boost.org/trac10/ticket/1180 <p> 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. </p> <div class="wiki-code"><div class="code"><pre><span class="k">struct</span> <span class="n">my_s</span> <span class="p">{</span> <span class="kt">int</span> <span class="n">a</span><span class="p">;</span> <span class="p">};</span> <span class="kt">void</span> <span class="n">export_module</span> <span class="p">{</span> <span class="n">class_</span><span class="o">&lt;</span><span class="n">my_s</span> <span class="o">&gt;</span> <span class="n">s_class</span><span class="p">(</span><span class="s">&quot;my_s&quot;</span><span class="p">,</span> <span class="n">init</span><span class="o">&lt;</span> <span class="o">&gt;</span><span class="p">());</span> <span class="n">s_class</span><span class="p">.</span><span class="n">def_readwrite</span><span class="p">(</span><span class="s">&quot;a&quot;</span><span class="p">,</span> <span class="o">&amp;</span><span class="n">my_s</span><span class="o">::</span><span class="n">a</span><span class="p">);</span><span class="c1">// __doc__ is empty, can boost.python add the type name of my_s::a as the default docstring? like the function&#39;s &quot;C++ signature&quot; docstring.</span> <span class="p">}</span> <span class="c1">// I do this like this:</span> <span class="c1">// get type name of data member of class </span> <span class="k">template</span><span class="o">&lt;</span><span class="k">typename</span> <span class="n">T</span><span class="p">,</span> <span class="k">typename</span> <span class="n">C</span><span class="o">&gt;</span> <span class="kt">char</span> <span class="k">const</span><span class="o">*</span> <span class="n">MemberTypeName</span><span class="p">(</span><span class="n">T</span> <span class="n">C</span><span class="o">::*</span><span class="p">)</span> <span class="p">{</span> <span class="kt">char</span> <span class="k">const</span><span class="o">*</span> <span class="n">name</span> <span class="o">=</span> <span class="k">typeid</span><span class="p">(</span><span class="n">T</span><span class="p">).</span><span class="n">name</span><span class="p">();</span> <span class="k">return</span> <span class="n">name</span><span class="p">;</span> <span class="p">}</span> <span class="c1">// boost::python def_readwrite no docstring</span> <span class="c1">// read write property</span> <span class="cp">#define DEF_READWRITE(n, p) \</span> <span class="cp"> def_readwrite((n), (p), std::string(&quot;read write property, type is &quot;) + MemberTypeName(p)).c_str())</span> <span class="kt">void</span> <span class="n">export_module</span> <span class="p">{</span> <span class="n">class_</span><span class="o">&lt;</span><span class="n">my_s</span> <span class="o">&gt;</span> <span class="n">s_class</span><span class="p">(</span><span class="s">&quot;my_s&quot;</span><span class="p">,</span> <span class="n">init</span><span class="o">&lt;</span> <span class="o">&gt;</span><span class="p">());</span> <span class="n">s_class</span><span class="p">.</span><span class="n">DEF_READWRITE</span><span class="p">(</span><span class="s">&quot;a&quot;</span><span class="p">,</span> <span class="o">&amp;</span><span class="n">my_s</span><span class="o">::</span><span class="n">a</span><span class="p">);</span><span class="c1">// replace all auto genarated def_readwrite to DEF_READWRITE.</span> <span class="p">}</span> </pre></div></div> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/1180 Trac 1.4.3 Dave Abrahams Thu, 26 Jun 2008 20:58:38 GMT description changed https://svn.boost.org/trac10/ticket/1180#comment:1 https://svn.boost.org/trac10/ticket/1180#comment:1 <ul> <li><strong>description</strong> modified (<a href="/trac10/ticket/1180?action=diff&amp;version=1">diff</a>) </li> </ul> <p> Fix formatting mess. </p> Ticket Dave Abrahams Thu, 26 Jun 2008 21:02:33 GMT status changed; cc set https://svn.boost.org/trac10/ticket/1180#comment:2 https://svn.boost.org/trac10/ticket/1180#comment:2 <ul> <li><strong>cc</strong> <span class="trac-author">rwgk@…</span> added </li> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> </ul> <p> Not sure if this makes sense. Ralf, what do you think? </p> Ticket Ralf W. Grosse-Kunstleve Fri, 27 Jun 2008 01:31:20 GMT <link>https://svn.boost.org/trac10/ticket/1180#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/1180#comment:3</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/1180#comment:2" title="Comment 2">dave</a>: </p> <blockquote class="citation"> <p> Not sure if this makes sense. Ralf, what do you think? </p> </blockquote> <p> I'm having trouble making sense of this, too. In Python: </p> <p> s = my_s() print s.a # that's a plain Python int print s.a.<span class="underline">doc</span> # Python int <span class="underline">doc</span> </p> <p> What would be the Python syntax to get to the C++ doc? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>troy d. straszheim</dc:creator> <pubDate>Sun, 01 Nov 2009 20:00:28 GMT</pubDate> <title>owner, status changed https://svn.boost.org/trac10/ticket/1180#comment:4 https://svn.boost.org/trac10/ticket/1180#comment:4 <ul> <li><strong>owner</strong> changed from <span class="trac-author">Dave Abrahams</span> to <span class="trac-author">troy d. straszheim</span> </li> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">new</span> </li> </ul> <p> Here's the difference between one documented and one undocumented property from the properties test (1.40.0): </p> <blockquote class="citation"> <blockquote class="citation"> <blockquote class="citation"> <p> help(properties_ext.X.value_r) </p> </blockquote> </blockquote> </blockquote> <p> Help on property: </p> <blockquote class="citation"> <blockquote class="citation"> <blockquote class="citation"> <p> help(proeprties_ext.X.value_r_ds) </p> </blockquote> </blockquote> </blockquote> <p> Help on property: </p> <blockquote> <p> value_r_ds is read-only </p> </blockquote> Ticket