On 11 March 2010 04:57, Craig Citro <[email protected]> wrote: > Hi Lisandro, > >> BTW, Any suggestions about docstring generation? I mean: >> > > So I'm going to jump in and make a few comments on this thread without > actually reading the whole thing first (always a dangerous move) ... > > I just want to give you the heads-up that support for docstrings on > Cython properties is currently in iffy shape. I ended up wrestling > with this a little bit while trying to get Cython to build Sage -- I'm > planning on filing a handful of trac tickets (and hopefully working up > some fixes) as soon as I've got an 0.13 alpha that can build Sage with > type inferencing turned on. > > I think that no one's really tried out docstrings with properties > before: they don't really play together well. Here are two big issues > I've hit so far ... let's say we've got a class Foo with property > my_prop: >
See my own code: http://code.google.com/p/mpi4py/source/browse/trunk/src/MPI/Comm.pyx#55 > * I don't know how to get my hands on the docstring for > Foo.my_prop.__get__ or Foo.my_prop.__set__ at all. I made a cursory > glance through the C code, and wasn't sure that it was correctly > getting attached anywhere, but it does at least appear in the C file. You have to add the docstrings at the top-level of the property block. > Actually, that's not completely true -- if the autotestdict is turned > on, then the docstring comes up in mod.__test__. Ups. That's a bug. > > I was planning on starting a new thread once I had some more concrete > suggestions for fixes. But here you are talking about @property defined at the Python level. In case of a cdef class, Cython does a different thing at the C level (i.e. filling the tp_getset slot of the PyTypeObject struct). > For comparison, Python attaches the docstrings > to the Foo.my_prop.fget, fset, and fdel methods. (The > Foo.my_prop.__get__ and whatnot all have generic docstrings.) Perhaps Cython could append the docstrings from __get__/__set__/__del__ to the top-level docstring? IIRC, Stefan did something similar for __cinit__ docstrings. -- Lisandro Dalcin --------------- Centro Internacional de Métodos Computacionales en Ingeniería (CIMEC) Instituto de Desarrollo Tecnológico para la Industria Química (INTEC) Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET) PTLC - Güemes 3450, (3000) Santa Fe, Argentina Tel/Fax: +54-(0)342-451.1594 _______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
