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

This commit is contained in:
Takeshi KOMIYA
2018-09-17 15:10:16 +09:00
parent 6d55e98da1
commit 9e8434f902
4 changed files with 17 additions and 1 deletions

View File

@@ -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
--------

View File

@@ -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:

View File

@@ -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

View File

@@ -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',