mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix #5436: Autodoc does not work with enum subclasses with properties/methods
This commit is contained in:
1
CHANGES
1
CHANGES
@@ -20,6 +20,7 @@ Bugs fixed
|
||||
* #5421: autodoc emits deprecation warning for :confval:`autodoc_default_flags`
|
||||
* #5422: lambda object causes PicklingError on storing environment
|
||||
* #5417: Sphinx fails to build with syntax error in Python 2.7.5
|
||||
* #5436: Autodoc does not work with enum subclasses with properties/methods
|
||||
|
||||
Testing
|
||||
--------
|
||||
|
||||
@@ -16,7 +16,7 @@ import warnings
|
||||
from collections import namedtuple
|
||||
from types import FunctionType, MethodType, ModuleType
|
||||
|
||||
from six import PY2
|
||||
from six import PY2, iteritems
|
||||
|
||||
from sphinx.util import logging
|
||||
from sphinx.util.inspect import isenumclass, safe_getattr
|
||||
@@ -248,6 +248,11 @@ def get_object_members(subject, objpath, attrgetter, analyzer=None):
|
||||
if name not in members:
|
||||
members[name] = Attribute(name, True, value)
|
||||
|
||||
superclass = subject.__mro__[1]
|
||||
for name, value in iteritems(obj_dict):
|
||||
if name not in superclass.__dict__:
|
||||
members[name] = Attribute(name, True, value)
|
||||
|
||||
# other members
|
||||
for name in dir(subject):
|
||||
try:
|
||||
|
||||
@@ -13,3 +13,7 @@ class EnumCls(enum.Enum):
|
||||
val3 = 34
|
||||
"""doc for val3"""
|
||||
val4 = 34
|
||||
|
||||
def say_hello(self):
|
||||
"""a method says hello to you."""
|
||||
pass
|
||||
|
||||
@@ -1271,6 +1271,12 @@ def test_enum_class(app):
|
||||
' this is enum class',
|
||||
' ',
|
||||
' ',
|
||||
' .. py:method:: EnumCls.say_hello()',
|
||||
' :module: target.enum',
|
||||
' ',
|
||||
' a method says hello to you.',
|
||||
' ',
|
||||
' ',
|
||||
' .. py:attribute:: EnumCls.val1',
|
||||
' :module: target.enum',
|
||||
' :annotation: = 12',
|
||||
|
||||
Reference in New Issue
Block a user