summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Ruana <rob@robruana.com>2016-11-23 10:45:39 -0800
committerRob Ruana <rob@robruana.com>2016-11-23 10:45:39 -0800
commitf45fe6fc8ca95f5b71b57b0ab80a3a44560c0295 (patch)
treeda41b94ebe064b6f557aabdfa7b4d97dc8486d95
parent4dbafaa7339ecfc00c397b1651e60fcc493d7dd0 (diff)
downloadsphinx-git-f45fe6fc8ca95f5b71b57b0ab80a3a44560c0295.tar.gz
Fix #3174: [Napoleon] Defers autodoc-skip-member to other extensions if Napoleon doesn't care if the member is skipped
-rw-r--r--doc/ext/autodoc.rst5
-rw-r--r--setup.cfg2
-rw-r--r--sphinx/ext/napoleon/__init__.py2
-rw-r--r--tests/test_ext_napoleon.py10
4 files changed, 12 insertions, 7 deletions
diff --git a/doc/ext/autodoc.rst b/doc/ext/autodoc.rst
index 63c959869..50004e575 100644
--- a/doc/ext/autodoc.rst
+++ b/doc/ext/autodoc.rst
@@ -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"``,
diff --git a/setup.cfg b/setup.cfg
index a65719461..533a71b0a 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -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/*
diff --git a/sphinx/ext/napoleon/__init__.py b/sphinx/ext/napoleon/__init__.py
index b74dfb75d..f6fccac7d 100644
--- a/sphinx/ext/napoleon/__init__.py
+++ b/sphinx/ext/napoleon/__init__.py
@@ -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
diff --git a/tests/test_ext_napoleon.py b/tests/test_ext_napoleon.py
index 21d095a79..5f68ba7c0 100644
--- a/tests/test_ext_napoleon.py
+++ b/tests/test_ext_napoleon.py
@@ -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):