Skip to content

[BUG] docs for cpdef enum ignored #3805

@matham

Description

@matham

Describe the bug

I have a cpdef enum and I'm trying to get the doc for it in python, but it doesn't seem to be available in the __doc__ attribute and the expected syntax for writing it is also seemingly invalid. And this is even with embedsignature=True.

I set up a demo example so you can see it failing in the tests:

To Reproduce

First I tried the class syntax, like python's enum:

cpdef enum Numbers:
    """Number list."""

    one = 1
    two = 2

But that gives:

Error compiling Cython file:
------------------------------------------------------------
...
        """
        return self.a + self.b


cpdef enum Numbers:
    """Number list."""
   ^
------------------------------------------------------------

cython_demo_project\numeric.pyx:22:4: Expected an identifier

So I tried:

cpdef enum Numbers:
    one = 1
    two = 2
"""Number list."""

But that gives:

>>> print(Numbers.__doc__)
An enumeration.

Expected behavior
My ultimate goal is to have the docs show up in sphinx doc generation. But, currently it doesn't seem to be at all included by Cython in the generated code.

Environment (please complete the following information):

  • OS: Windows
  • Python version: 3.7.3.
  • Cython version 0.29.21

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions