Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autodoc not rendering docs for classmethod on IntEnum class #6857

Closed
chrisjbillington opened this issue Nov 23, 2019 · 3 comments
Closed

Autodoc not rendering docs for classmethod on IntEnum class #6857

chrisjbillington opened this issue Nov 23, 2019 · 3 comments

Comments

@chrisjbillington
Copy link

The classmethod in the below class is not getting picked up by autodoc when I include the class with the following:

.. autoclass:: inotify_simple.flags
    :members:
class flags(enum.IntEnum):
    """Inotify flags as defined in ``inotify.h`` but with ``IN_`` prefix omitted.
    Includes a convenience method :func:`~inotify_simple.flags.from_mask` for extracting
    flags from a mask.
    """
    @classmethod
    def from_mask(cls, mask):
        """Convenience method that returns a list of every flag in a mask."""
        return [flag for flag in cls.__members__.values() if flag & mask]

    ACCESS = 0x00000001  #: File was accessed
    MODIFY = 0x00000002  #: File was modified
    ...

To Reproduce
Steps to reproduce the behavior:

$ git clone https://github.com/chrisjbillington/inotify_simple
$ cd inotify_simple/doc
$ make html

Then open build/html/index.html and scroll down to or ctrl-f for the classinotify_simple.flags docs, and see that the from_mask() method documentation is not present.

Expected behavior
To see the method documentation for from_mask() under the class.

If I either:

  • change the class to not be a subclass of enum.IntEnum or
  • make the method not a classmethod

then I do see the documentation:

image

So it's an issue specific to the enum class and classmethods.

If I add :undoc-members: then I see the member, but without its function signature or docstring:

image

Your project
https://github.com/chrisjbillington/inotify_simple

Environment info

  • OS: Arch Linux, fully updated
  • Python version: 3.8.0
  • Sphinx version: 2.2.1
  • Sphinx extensions: sphinx.ext.autodoc, sphinx.ext.napoleon

Readthedocs also fails to render the docs for this classmethod, so the issue is probably not super specific to my environment.

@chrisjbillington
Copy link
Author

Closed thinking I had found the cause and that it was my fault, reopened as it turned out that was not the case.

@chrisjbillington
Copy link
Author

A more minimal example of the bug:

bug_demo.zip

make with make html.

@jamesharris-garmin
Copy link

I'm seeing this issue as well. I wonder if there is a clean solution for this.

@tk0miya tk0miya added this to the 3.1.0 milestone Apr 30, 2020
@tk0miya tk0miya closed this as completed in d612ef8 May 2, 2020
tk0miya added a commit that referenced this issue May 2, 2020
Fix #6857: autodoc: failed to detect a classmethod on Enum class
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 25, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants