Search code examples
cythonpython-sphinxautodoc

Get Sphinx to autodoc my Cython class's __init__


I have this Cython class:

cdef class Sprite:
    def __init__(self, someargument):
        pass

And I want Sphinx to document it like this:

class Sprite(self, texture)
    Does stuff.

so I tried documenting it:

cdef class Sprite:
    def __init__(self, someargument):
        """__init__(self, someargument)

        Does stuff."""

        pass

But it didn't even show up. I even tried this:

cdef class Sprite:
    """Sprite(self, someargument)

    Does stuff."""

    def __init__(self, someargument):
        pass

This time it did show up, but sphinx didn't do it's magic stuff with this information like it normally does:

class Sprite
    Sprite(self, texture)

    Does stuff.

So how must I do it?


Solution

  • It turned out to be a bug, I added a bug report and a fix here:

    https://bitbucket.org/birkenfeld/sphinx/issue/866/sphinx-doesnt-check-an-init-docstring#comment-1012906