Commits

Rob Ruana committed 73418c5

Closes #1418: Private and special members are properly skipped on Python 3.3

  • Participants
  • Parent commits efb88c8

Comments (0)

Files changed (4)

 
 -------------------------------------------------------------------------------
 
-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:
 
 -------------------------------------------------------------------------------
 

sphinx/ext/napoleon/__init__.py

     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

sphinx/ext/napoleon/docstring.py

                            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.
 
         func_name1, func_name2, :meth:`func_name`, func_name3
 
         """
-        content = self._consume_to_next_section()
         items = []
 
         def parse_item_name(text):
         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(':'):
                 rest.append(line.strip())
         push_item(current_func, rest)
 
-
         if not items:
             return []
 

tests/test_napoleon_docstring.py

         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)
 
         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)