summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Ruana <rob@relentlessidiot.com>2014-03-11 03:50:49 -0400
committerRob Ruana <rob@relentlessidiot.com>2014-03-11 03:50:49 -0400
commitae1e88428e8729940a1bf9c83c373c19172092e3 (patch)
tree2e771c41a5d71617b98b72ea4875c511c26f59a7
parent01d98d34ad010f38204540677e447a3d38adee4e (diff)
downloadsphinx-ae1e88428e8729940a1bf9c83c373c19172092e3.tar.gz
Closes #1418: Private and special members are properly skipped on Python 3.3
-rw-r--r--LICENSE4
-rw-r--r--sphinx/ext/napoleon/__init__.py6
-rw-r--r--sphinx/ext/napoleon/docstring.py12
-rw-r--r--tests/test_napoleon_docstring.py7
4 files changed, 19 insertions, 10 deletions
diff --git a/LICENSE b/LICENSE
index 85ce4a1d..c8a79284 100644
--- a/LICENSE
+++ b/LICENSE
@@ -247,8 +247,8 @@ OTHER DEALINGS IN THE SOFTWARE.
-------------------------------------------------------------------------------
-The included implementation of NumpyDocstring._parse_see_also_section was
-derived from code under the following license:
+The included implementation of NumpyDocstring._parse_numpydoc_see_also_section
+was derived from code under the following license:
-------------------------------------------------------------------------------
diff --git a/sphinx/ext/napoleon/__init__.py b/sphinx/ext/napoleon/__init__.py
index 08ca0eff..bceabd23 100644
--- a/sphinx/ext/napoleon/__init__.py
+++ b/sphinx/ext/napoleon/__init__.py
@@ -344,14 +344,16 @@ def _skip_member(app, what, name, obj, skip, options):
has_doc = getattr(obj, '__doc__', False)
is_member = (what == 'class' or what == 'exception' or what == 'module')
if name != '__weakref__' and name != '__init__' and has_doc and is_member:
+ cls_is_owner = False
if what == 'class' or what == 'exception':
if sys.version_info[0] < 3:
cls = getattr(obj, 'im_class', getattr(obj, '__objclass__',
None))
cls_is_owner = (cls and hasattr(cls, name) and
name in cls.__dict__)
- elif sys.version_info[1] >= 3 and hasattr(obj, '__qualname__'):
- cls_path, _, _ = obj.__qualname__.rpartition('.')
+ elif sys.version_info[1] >= 3:
+ qualname = getattr(obj, '__qualname__', '')
+ cls_path, _, _ = qualname.rpartition('.')
if cls_path:
import importlib
import functools
diff --git a/sphinx/ext/napoleon/docstring.py b/sphinx/ext/napoleon/docstring.py
index d99245c9..24f4423e 100644
--- a/sphinx/ext/napoleon/docstring.py
+++ b/sphinx/ext/napoleon/docstring.py
@@ -743,6 +743,13 @@ class NumpyDocstring(GoogleDocstring):
r" (?P<name2>[a-zA-Z0-9_.-]+))\s*", re.X)
def _parse_see_also_section(self, section):
+ lines = self._consume_to_next_section()
+ try:
+ return self._parse_numpydoc_see_also_section(lines)
+ except ValueError:
+ return self._format_admonition('seealso', lines)
+
+ def _parse_numpydoc_see_also_section(self, content):
"""
Derived from the NumpyDoc implementation of _parse_see_also.
@@ -752,7 +759,6 @@ class NumpyDocstring(GoogleDocstring):
func_name1, func_name2, :meth:`func_name`, func_name3
"""
- content = self._consume_to_next_section()
items = []
def parse_item_name(text):
@@ -777,7 +783,8 @@ class NumpyDocstring(GoogleDocstring):
rest = []
for line in content:
- if not line.strip(): continue
+ if not line.strip():
+ continue
m = self._name_rgx.match(line)
if m and line[m.end():].strip().startswith(':'):
@@ -799,7 +806,6 @@ class NumpyDocstring(GoogleDocstring):
rest.append(line.strip())
push_item(current_func, rest)
-
if not items:
return []
diff --git a/tests/test_napoleon_docstring.py b/tests/test_napoleon_docstring.py
index 61b9efe2..268fc1eb 100644
--- a/tests/test_napoleon_docstring.py
+++ b/tests/test_napoleon_docstring.py
@@ -278,8 +278,8 @@ class NumpyDocstringTest(BaseDocstringTest):
config = Config(napoleon_use_param=False)
actual = str(NumpyDocstring(textwrap.dedent(docstring), config))
expected = textwrap.dedent("""
- :Parameters: **param1** (:class:`MyClass <name.space.MyClass>` instance)
- """)
+:Parameters: **param1** (:class:`MyClass <name.space.MyClass>` instance)
+""")
self.assertEqual(expected, actual)
config = Config(napoleon_use_param=True)
@@ -348,7 +348,8 @@ numpy.multivariate_normal(mean, cov, shape=None, spam=None)
config = Config()
app = Mock()
- actual = str(NumpyDocstring(textwrap.dedent(docstring), config, app, "method"))
+ actual = str(NumpyDocstring(textwrap.dedent(docstring),
+ config, app, "method"))
expected = """
numpy.multivariate_normal(mean, cov, shape=None, spam=None)