[C++-sig] Better introspection/apidoc extraction support?
Hans Meine
meine at informatik.uni-hamburg.de
Tue May 15 13:37:24 CEST 2007
Hi!
Am Montag, 14. Mai 2007 17:59:00 schrieb Ralf W. Grosse-Kunstleve:
> I did the implementation of the "docstring_options" feature. I'm not aware
> of plans to work on this, but I'm interested to at least learn what could
> be done to better support epydoc. If it is not too time-consuming I'd be
> willing to work on it a bit.
Great!
> > The epydoc developers would like to support boost::python function
> > introspection. In boost 1.34.0, there is support for C++ signatures
> > appended to the docstrings, but it would be better AFAICS if
> > boost::python would additionally provide means for extracting the
> > argument names and default values via ("half-private") attributes,
> > similar to CPython.
>
> How exactly does this work? Are there web pages about this?
Not that I know of. AFAICS, there is no public API for that (that's why I
wrote "half-private"), but if you look at a functions func_code.co_XXX and
func_defaults properties, you see that there is a lot of internal information
available in CPython.
Then, there is the inspect module (implemented in python), which uses the
above internal stuff to offer a more convenient API. E.g.
inspect.getargspec() uses func_code.co_varnames[:func_code.co_argcount] to
query the argument names, func_code.co_flags to determine whether the
function has *args or **kwargs parameters (4/8 bitflags), ...
I would think that basically *any* API within boost::python functions would be
OK, since there is no official way beyond inspect. (Of course, it would be
best if the inspect module would become compatible with boost::python some
day, so apidoc projects do not have to duplicate code..)
--
Ciao, / /
/--/
/ / ANS
More information about the Cplusplus-sig
mailing list