You look a litte bit confused here. Sphinx is not really a syntactic analyzer. Your Python code has to be runnable to make Sphinx able to catch the docstrings. That is why renaming the extensions files to ".py" doesn't help.
Well, I've been working with Sphinx and Cython recently, and would like to share my experience... Here's the full detailed procedure to get the automated generation of an html documentation for a given compiled Cython extension from docstrings :
[Note : I used Sphinx 1.1.3 and Cython 0.17.4]
First of all, use the Python's "docstrings" (with all the limitations it can have - by example, you can't describe a constructor. See docstrings specifications) in your Cython code :
cdef class PyLabNode:
"""
This is a LabNode !!!
"""
cdef LabNode* thisptr
cdef PyLabNetwork network
def __cinit__(self):
self.thisptr = new LabNode()
def __dealloc__(self):
if self.thisptr:
del self.thisptr
def SetNetwork(self, PyLabNetwork net):
"""
Set the network !!!
"""
self.network = net
And recompile "yourextension.so".
Then run "sphinx-quickstart" and answer the questions. Do not forget to say yes when asked for "autodoc". This will generate the "Makefile", the "index.rst" file and the "conf.py" files.
This last "conf.py" has to be edited to tell Sphinx were to find your module :
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#sys.path.insert(0, os.path.abspath('.'))
sys.path.insert(0, os.path.abspath('../../parent/dir/of/yourextension/'))
The "index.rst" file has to be edited as well to tell which module might be analyzed :
Contents:
.. toctree::
:maxdepth: 2
.. automodule:: yourextension
:members:
:undoc-members:
:show-inheritance:
Finally build the documentation by doing :
$ make html
That was enough for me (I got the resulting set of html files in a ".../_build/html/" directory). May be Sphinx and Cython have evolved since the previous question was asked, but I had no "signature" issues to deal with. No particular Cython directive to use, nor any fix to apply to Sphinx...
Hope this helps.
EDIT : Well, I would like to take my words back. I encountered the issue "Dan" was mentioning concerning the "embedsignature" matter while using Epydoc (so I suppose this is an issue with Sphinx as well). Activating this compiler directive doesn't send python compliant signatures anyway :
PyLabNode.SetNetwork(self, PyLabNetwork net)
This has 2 drawback : The dotted notation for the class prefix and the typed parameter.
At the end, the only way I could figure out to send correct ones was to write a compliant signature at the very first line of the doc strings like so :
def SetNetwork(self, PyLabNetwork net):
"""
SetNetwork(self, net)
Set the net !!!
@param self: Handler to this.
@type self: L{PyLabNode}
@param net: The network this node belongs to.
@type net: L{PyLabNetwork}
"""
self.network = net
Hope this can help both Sphinx and Epydoc users...
EDIT : Concerning the __cinit__
, I was able to generate the doc successfully with Epidoc
(didn't try with Sphinx) by doubling the description, like this:
# For Epydoc only (only used for docstring)
def __init__(self, sim):
"""
__init__(self, sim)
Constructor.
@param sim: The simulator this binding is attached to.
@type sim: L{PyLabSimulatorBase}
"""
# Real Cython init
def __cinit__(self, PyLabSimulatorBase sim):
self.thisptr = new LabNetBinding()
self.sites = []
simulator = sim