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 does not work with enum subclasses with properties/methods #5436

Closed
albireox opened this issue Sep 15, 2018 · 3 comments
Closed

Autodoc does not work with enum subclasses with properties/methods #5436

albireox opened this issue Sep 15, 2018 · 3 comments

Comments

@albireox
Copy link

Subject: Autodoc does not work with enum subclasses with properties/methods

Problem

  • When a subclass of enum.Flag or enum.IntFlag has additional methods or properties, those are not displayed by autodoc.

Procedure to reproduce the problem

I have this enumeration

class Maskbit(enum.Flag):
    """A maskbit enumeration. Intended for subclassing."""

    @property
    def active_bits(self):
        """Returns a list of flags that match the value."""

        return [bit for bit in self.__class__ if bit.value & self.value]

When documenting it with

.. automodule:: jaeger.utils.maskbits
    :undoc-members:

it shoes the doctoring for the class but not the property or its docstring. The same is true if active_bits is a method.

Error logs / results

  • No errors but the output is not the expected one.

Expected results

  • Subclasses of enum should be documented as normal classes.

Reproducible project / your project

  • See snippet above. If needed I can provide the full project but shouldn't be necessary.

Environment info

  • OS: macOS 10.14
  • Python version: 3.7.0
  • Sphinx version: v1.8.0
@tk0miya
Copy link
Member

tk0miya commented Sep 16, 2018

Thank you for reporting!

Note:
With 3.7, it seems active_bits is not listed on the attributes list:

>>> dir(Maskbit)
['__class__', '__doc__', '__members__', '__module__']
>>> Maskbit.__members__
mappingproxy(OrderedDict())

And I found it on internal dictionary: __dict__

>>> Maskbit.__dict__
mappingproxy({'_generate_next_value_': <function Flag._generate_next_value_ at 0x10405e2f0>, '__module__': '__main__', '__doc__': 'A maskbit enumeration. Intended for subclassing.', 'active_bits': <property object at 0x103f85098>, '_member_names_': [], '_member_map_': OrderedDict(), '_member_type_': <class 'object'>, '_value2member_map_': {}, '__new__': <function Enum.__new__ at 0x10405da60>})

I don't know other interpreters works as same.

@albireox
Copy link
Author

Seems the same is true in 3.6.

tk0miya added a commit to tk0miya/sphinx that referenced this issue Sep 17, 2018
tk0miya added a commit to tk0miya/sphinx that referenced this issue Sep 18, 2018
tk0miya added a commit that referenced this issue Sep 18, 2018
…sses

Fix #5436: Autodoc does not work with enum subclasses with properties/methods
@tk0miya
Copy link
Member

tk0miya commented Sep 18, 2018

Fixed by #5449.
Thanks,

@tk0miya tk0miya closed this as completed Sep 18, 2018
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 11, 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

2 participants