mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix #5139: autodoc: Enum argument missing if it shares value with another
This commit is contained in:
parent
62dbe44858
commit
b1acc54cf9
1
CHANGES
1
CHANGES
@ -42,6 +42,7 @@ Bugs fixed
|
|||||||
* autosummary: warnings of autosummary indicates wrong location (refs: #5146)
|
* autosummary: warnings of autosummary indicates wrong location (refs: #5146)
|
||||||
* #5143: autodoc: crashed on inspecting dict like object which does not support
|
* #5143: autodoc: crashed on inspecting dict like object which does not support
|
||||||
sorting
|
sorting
|
||||||
|
* #5139: autodoc: Enum argument missing if it shares value with another
|
||||||
|
|
||||||
Testing
|
Testing
|
||||||
--------
|
--------
|
||||||
|
@ -219,12 +219,21 @@ def get_object_members(subject, objpath, attrgetter, analyzer=None):
|
|||||||
for name, value in subject.__members__.items():
|
for name, value in subject.__members__.items():
|
||||||
obj_dict[name] = value
|
obj_dict[name] = value
|
||||||
|
|
||||||
members = {}
|
members = {} # type: Dict[str, Attribute]
|
||||||
|
|
||||||
|
# enum members
|
||||||
|
if isenumclass(subject):
|
||||||
|
for name, value in subject.__members__.items():
|
||||||
|
if name not in members:
|
||||||
|
members[name] = Attribute(name, True, value)
|
||||||
|
|
||||||
|
# other members
|
||||||
for name in dir(subject):
|
for name in dir(subject):
|
||||||
try:
|
try:
|
||||||
value = attrgetter(subject, name)
|
value = attrgetter(subject, name)
|
||||||
directly_defined = name in obj_dict
|
directly_defined = name in obj_dict
|
||||||
members[name] = Attribute(name, directly_defined, value)
|
if name not in members:
|
||||||
|
members[name] = Attribute(name, directly_defined, value)
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
@ -233,3 +233,4 @@ class EnumCls(enum.Enum):
|
|||||||
val2 = 23 #: doc for val2
|
val2 = 23 #: doc for val2
|
||||||
val3 = 34
|
val3 = 34
|
||||||
"""doc for val3"""
|
"""doc for val3"""
|
||||||
|
val4 = 34
|
||||||
|
@ -873,13 +873,14 @@ def test_generate():
|
|||||||
# test members with enum attributes
|
# test members with enum attributes
|
||||||
directive.env.ref_context['py:module'] = 'target'
|
directive.env.ref_context['py:module'] = 'target'
|
||||||
options.inherited_members = False
|
options.inherited_members = False
|
||||||
options.undoc_members = False
|
options.undoc_members = True
|
||||||
options.members = ALL
|
options.members = ALL
|
||||||
assert_processes([
|
assert_processes([
|
||||||
('class', 'target.EnumCls'),
|
('class', 'target.EnumCls'),
|
||||||
('attribute', 'target.EnumCls.val1'),
|
('attribute', 'target.EnumCls.val1'),
|
||||||
('attribute', 'target.EnumCls.val2'),
|
('attribute', 'target.EnumCls.val2'),
|
||||||
('attribute', 'target.EnumCls.val3'),
|
('attribute', 'target.EnumCls.val3'),
|
||||||
|
('attribute', 'target.EnumCls.val4'),
|
||||||
], 'class', 'EnumCls')
|
], 'class', 'EnumCls')
|
||||||
assert_result_contains(
|
assert_result_contains(
|
||||||
' :annotation: = 12', 'attribute', 'EnumCls.val1')
|
' :annotation: = 12', 'attribute', 'EnumCls.val1')
|
||||||
|
Loading…
Reference in New Issue
Block a user