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

This commit is contained in:
Rob Ruana 2014-03-11 03:50:49 -04:00
parent 191e0b4c12
commit 3e7ce5d3a1
4 changed files with 19 additions and 10 deletions

View File

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

View File

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

View File

@ -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 []

View File

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