Fix #6857: autodoc: failed to detect a classmethod on Enum class

This commit is contained in:
Takeshi KOMIYA 2020-04-30 22:54:49 +09:00
parent 5460ad6925
commit d612ef8f0b
4 changed files with 16 additions and 8 deletions

View File

@ -74,6 +74,7 @@ Bugs fixed
* #6588: autodoc: Decorated inherited method has no documentation
* #7469: autodoc: The change of autodoc-process-docstring for variables is
cached unexpectedly
* #6857: autodoc: failed to detect a classmethod on Enum class
* #7535: sphinx-autogen: crashes when custom template uses inheritance
* #7536: sphinx-autogen: crashes when template uses i18n feature
* #2785: html: Bad alignment of equation links

View File

@ -142,8 +142,9 @@ def get_object_members(subject: Any, objpath: List[str], attrgetter: Callable,
members[name] = Attribute(name, True, value)
superclass = subject.__mro__[1]
for name, value in obj_dict.items():
for name in obj_dict:
if name not in superclass.__dict__:
value = safe_getattr(subject, name)
members[name] = Attribute(name, True, value)
# members in __slots__

View File

@ -16,3 +16,8 @@ class EnumCls(enum.Enum):
def say_hello(self):
"""a method says hello to you."""
pass
@classmethod
def say_goodbye(cls):
"""a classmethod says good-bye to you."""
pass

View File

@ -1112,8 +1112,7 @@ def test_slots(app):
@pytest.mark.sphinx('html', testroot='ext-autodoc')
def test_enum_class(app):
options = {"members": None,
"undoc-members": True}
options = {"members": None}
actual = do_autodoc(app, 'class', 'target.enum.EnumCls', options)
assert list(actual) == [
'',
@ -1123,6 +1122,13 @@ def test_enum_class(app):
' this is enum class',
'',
'',
' .. py:method:: EnumCls.say_goodbye()',
' :module: target.enum',
' :classmethod:',
'',
' a classmethod says good-bye to you.',
'',
'',
' .. py:method:: EnumCls.say_hello()',
' :module: target.enum',
'',
@ -1149,11 +1155,6 @@ def test_enum_class(app):
'',
' doc for val3',
'',
'',
' .. py:attribute:: EnumCls.val4',
' :module: target.enum',
' :value: 34',
''
]
# checks for an attribute of EnumClass