Fix #3174: [Napoleon] Defers autodoc-skip-member to other extensions if Napoleon doesn't care if the member is skipped

This commit is contained in:
Rob Ruana 2016-11-23 10:45:39 -08:00
parent 4dbafaa733
commit f45fe6fc8c
4 changed files with 12 additions and 7 deletions

View File

@ -446,6 +446,11 @@ member should be included in the documentation by using the following event:
documentation. The member is excluded if a handler returns ``True``. It is
included if the handler returns ``False``.
If more than one enabled extension handles the ``autodoc-skip-member``
event, autodoc will use the first non-``None`` value returned by a handler.
Handlers should return ``None`` to fall back to the skipping behavior of
autodoc and other enabled extensions.
:param app: the Sphinx application object
:param what: the type of the object which the docstring belongs to (one of
``"module"``, ``"class"``, ``"exception"``, ``"function"``, ``"method"``,

View File

@ -26,4 +26,4 @@ universal = 1
[flake8]
max-line-length=95
ignore=E113,E116,E221,E226,E241,E251,E901
exclude=tests/*,build/*,sphinx/search/*,sphinx/pycode/pgen2/*,doc/ext/example*.py
exclude=tests/*,build/*,sphinx/search/*,sphinx/pycode/pgen2/*,doc/ext/example*.py,.tox/*

View File

@ -464,4 +464,4 @@ def _skip_member(app, what, name, obj, skip, options):
(is_private and inc_private) or
(is_init and inc_init)):
return False
return skip
return None

View File

@ -123,19 +123,19 @@ class SetupTest(TestCase):
class SkipMemberTest(TestCase):
def assertSkip(self, what, member, obj, expect_skip, config_name):
skip = 'default skip'
def assertSkip(self, what, member, obj, expect_default_skip, config_name):
skip = True
app = mock.Mock()
app.config = Config()
setattr(app.config, config_name, True)
if expect_skip:
self.assertEqual(skip, _skip_member(app, what, member, obj, skip,
if expect_default_skip:
self.assertEqual(None, _skip_member(app, what, member, obj, skip,
mock.Mock()))
else:
self.assertFalse(_skip_member(app, what, member, obj, skip,
mock.Mock()))
setattr(app.config, config_name, False)
self.assertEqual(skip, _skip_member(app, what, member, obj, skip,
self.assertEqual(None, _skip_member(app, what, member, obj, skip,
mock.Mock()))
def test_namedtuple(self):