Sphinx documentation through autodoc for Python C modules

I am trying to document pycurl, which is pretty much a C extension module.

There are several classes written in C in this extension module. They have methods. These methods have defined dockers:

>>> help (pycurl.Curl (). close)
Help on built-in function close:

close (...)
    close () -> None. Close handle and end curl session.

But these methods are not defined on the classes themselves:

>>> dir (pycurl.Curl)
['__call__', '__class__', '__cmp__', '__delattr__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init __le__ ',' __lt__ ',' __module__ ',' __name__ ',' __ne__ ',' __new__ ',' __reduce__ ',' __reduce_ex__ ',' __repr__ ',' __self__ ',' __setattr__ ',' __sizeof__ '' __ , '__subclasshook__']
>>> pycurl.Curl.close
Traceback (most recent call last):
  File "", line 1, in 
AttributeError: 'builtin_function_or_method' object has no attribute 'close'

As a result, when I try to use automethod to document them, sphinx says that these methods do not exist:

    .. automethod:: pycurl.Curl.close

curlobject.rst:13: WARNING: autodoc: failed to import method u'Curl.close' from module u'pycurl'; the following exception was raised:
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/Sphinx-1.2-py2.7.egg/sphinx/ext/autodoc.py", line 342, in import_object
    obj = self.get_attr(obj, part)
  File "/usr/local/lib/python2.7/site-packages/Sphinx-1.2-py2.7.egg/sphinx/ext/autodoc.py", line 241, in get_attr
    return safe_getattr(obj, name, *defargs)
  File "/usr/local/lib/python2.7/site-packages/Sphinx-1.2-py2.7.egg/sphinx/util/inspect.py", line 114, in safe_getattr
    raise AttributeError(name)
AttributeError: close

sphinx docstrings , C?

+3
source share

All Articles