Help with boost::python and documentation tools (e.g. pydoc)

Discussion in 'Python' started by Neal D. Becker, Sep 30, 2004.

  1. I'm using boost::python to transform various C++ classes and functions to
    python. It is all working quite well, but now I'm having trouble with
    documentation tools.

    I hope someone can tell me if the problem is with the doc tools, such as
    pydoc, or with boost::python implementation.

    If I create a free function, this is what happens:
    PyTypeObject function_type = {
    PyObject_HEAD_INIT(0)
    0,
    "Boost.Python.function",
    sizeof(function),
    0,
    (destructor)function_dealloc, /* tp_dealloc */
    0, /* tp_print */
    0, /* tp_getattr */
    0, /* tp_setattr */
    0, /* tp_compare */
    0, //(reprfunc)func_repr, /* tp_repr */
    0, /* tp_as_number */
    0, /* tp_as_sequence */
    0, /* tp_as_mapping */
    0, /* tp_hash */
    function_call, /* tp_call */
    0, /* tp_str */
    0, // PyObject_GenericGetAttr, /* tp_getattro */
    0, // PyObject_GenericSetAttr, /* tp_setattro */
    0, /* tp_as_buffer */
    Py_TPFLAGS_DEFAULT /* | Py_TPFLAGS_HAVE_GC */,/* tp_flags */
    0, /* tp_doc */
    0, // (traverseproc)func_traverse, /* tp_traverse */
    0, /* tp_clear */
    0, /* tp_richcompare */
    0, //offsetof(PyFunctionObject, func_weakreflist), /* tp_weaklistoffset
    */
    0, /* tp_iter */
    0, /* tp_iternext */
    0, /* tp_methods */
    0, // func_memberlist, /* tp_members */
    function_getsetlist, /* tp_getset */
    0, /* tp_base */
    0, /* tp_dict */
    function_descr_get, /* tp_descr_get */
    0, /* tp_descr_set */
    0, //offsetof(PyFunctionObject, func_dict), /* tp_dictoffset */
    0, /* tp_init */
    0, /* tp_alloc */
    0,
    0 /* tp_new */
    };

    Notice the getset member is being set, so I guess this is using the new
    descriptor protocol.

    As an example:

    dir (block_interleaver_wrap)
    ['__doc__', '__file__', '__name__', 'block_interleaver', 'deinterleave',
    'deinterleave_c', 'interleave', 'interleave_c']

    the latter 4 are free functions. If I use pydoc, these functions don't
    appear.

    inspect.ismethoddescriptor(block_interleaver_wrap.interleave)
    True

    inspect.getdoc (block_interleaver_wrap.interleave)
    'interleave(inter,x)\nInterleave input I{x} using interleaver I{inter}@param
    inter: stuff'

    This is the documentation I wanted.

    Anyone know what needs to happen so that tools like pydoc, and especially
    epydoc, will correctly find the documentation?
     
    Neal D. Becker, Sep 30, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. BartlebyScrivener

    pydoc script.py vs. pydoc scriptpy

    BartlebyScrivener, Oct 20, 2007, in forum: Python
    Replies:
    1
    Views:
    655
    Stargaming
    Oct 22, 2007
  2. News123
    Replies:
    0
    Views:
    300
    News123
    Feb 6, 2010
  3. Alexey Gaidamaka
    Replies:
    0
    Views:
    153
    Alexey Gaidamaka
    Jun 10, 2012
  4. Andrew Berg
    Replies:
    0
    Views:
    151
    Andrew Berg
    Jun 10, 2012
  5. Alexey Gaidamaka
    Replies:
    0
    Views:
    301
    Alexey Gaidamaka
    Jun 15, 2012
Loading...

Share This Page