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 741acb04e9
commit b7efbfe615
3 changed files with 11 additions and 6 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

@@ -453,4 +453,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):