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:

 * 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.
Actually, that's not completely true -- if the autotestdict is turned
on, then the docstring comes up in mod.__test__. This was actually
broken until a day or two ago (fixing it is how I ran into this whole
mess in the first place). But it clearly should get attached to Foo
somewhere. The fact that I couldn't find it another way is also why
the test that I submitted goes via the __test__ dict's keys, instead
of doing something more sane. (I plan to clean up the test once I fix
the issues with properties.)

 * If you try to give a docstring to Foo.my_prop.__del__, Cython
crashes. The underlying issue is this: we currently wrap the __set__
and __del__ methods into the "setter" part of a PyGetSetDef, so it's
not clear where to attach the __del__ docstring -- or, at least, where
to attach *both* a __set__ and __del__ docstring. (I don't think this
is insurmountable, but we might need to think harder.)

I was planning on starting a new thread once I had some more concrete
suggestions for fixes. 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.)

-cc
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to