mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix #6857: autodoc: failed to detect a classmethod on Enum class
This commit is contained in:
1
CHANGES
1
CHANGES
@@ -74,6 +74,7 @@ Bugs fixed
|
|||||||
* #6588: autodoc: Decorated inherited method has no documentation
|
* #6588: autodoc: Decorated inherited method has no documentation
|
||||||
* #7469: autodoc: The change of autodoc-process-docstring for variables is
|
* #7469: autodoc: The change of autodoc-process-docstring for variables is
|
||||||
cached unexpectedly
|
cached unexpectedly
|
||||||
|
* #6857: autodoc: failed to detect a classmethod on Enum class
|
||||||
* #7535: sphinx-autogen: crashes when custom template uses inheritance
|
* #7535: sphinx-autogen: crashes when custom template uses inheritance
|
||||||
* #7536: sphinx-autogen: crashes when template uses i18n feature
|
* #7536: sphinx-autogen: crashes when template uses i18n feature
|
||||||
* #2785: html: Bad alignment of equation links
|
* #2785: html: Bad alignment of equation links
|
||||||
|
|||||||
@@ -142,8 +142,9 @@ def get_object_members(subject: Any, objpath: List[str], attrgetter: Callable,
|
|||||||
members[name] = Attribute(name, True, value)
|
members[name] = Attribute(name, True, value)
|
||||||
|
|
||||||
superclass = subject.__mro__[1]
|
superclass = subject.__mro__[1]
|
||||||
for name, value in obj_dict.items():
|
for name in obj_dict:
|
||||||
if name not in superclass.__dict__:
|
if name not in superclass.__dict__:
|
||||||
|
value = safe_getattr(subject, name)
|
||||||
members[name] = Attribute(name, True, value)
|
members[name] = Attribute(name, True, value)
|
||||||
|
|
||||||
# members in __slots__
|
# members in __slots__
|
||||||
|
|||||||
@@ -16,3 +16,8 @@ class EnumCls(enum.Enum):
|
|||||||
def say_hello(self):
|
def say_hello(self):
|
||||||
"""a method says hello to you."""
|
"""a method says hello to you."""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def say_goodbye(cls):
|
||||||
|
"""a classmethod says good-bye to you."""
|
||||||
|
pass
|
||||||
|
|||||||
@@ -1112,8 +1112,7 @@ def test_slots(app):
|
|||||||
|
|
||||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||||
def test_enum_class(app):
|
def test_enum_class(app):
|
||||||
options = {"members": None,
|
options = {"members": None}
|
||||||
"undoc-members": True}
|
|
||||||
actual = do_autodoc(app, 'class', 'target.enum.EnumCls', options)
|
actual = do_autodoc(app, 'class', 'target.enum.EnumCls', options)
|
||||||
assert list(actual) == [
|
assert list(actual) == [
|
||||||
'',
|
'',
|
||||||
@@ -1123,6 +1122,13 @@ def test_enum_class(app):
|
|||||||
' this is enum class',
|
' 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()',
|
' .. py:method:: EnumCls.say_hello()',
|
||||||
' :module: target.enum',
|
' :module: target.enum',
|
||||||
'',
|
'',
|
||||||
@@ -1149,11 +1155,6 @@ def test_enum_class(app):
|
|||||||
'',
|
'',
|
||||||
' doc for val3',
|
' doc for val3',
|
||||||
'',
|
'',
|
||||||
'',
|
|
||||||
' .. py:attribute:: EnumCls.val4',
|
|
||||||
' :module: target.enum',
|
|
||||||
' :value: 34',
|
|
||||||
''
|
|
||||||
]
|
]
|
||||||
|
|
||||||
# checks for an attribute of EnumClass
|
# checks for an attribute of EnumClass
|
||||||
|
|||||||
Reference in New Issue
Block a user