mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Closes #1418: Private and special members are properly skipped on Python 3.3
This commit is contained in:
parent
191e0b4c12
commit
3e7ce5d3a1
4
LICENSE
4
LICENSE
@ -247,8 +247,8 @@ OTHER DEALINGS IN THE SOFTWARE.
|
|||||||
|
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
|
|
||||||
The included implementation of NumpyDocstring._parse_see_also_section was
|
The included implementation of NumpyDocstring._parse_numpydoc_see_also_section
|
||||||
derived from code under the following license:
|
was derived from code under the following license:
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -344,14 +344,16 @@ def _skip_member(app, what, name, obj, skip, options):
|
|||||||
has_doc = getattr(obj, '__doc__', False)
|
has_doc = getattr(obj, '__doc__', False)
|
||||||
is_member = (what == 'class' or what == 'exception' or what == 'module')
|
is_member = (what == 'class' or what == 'exception' or what == 'module')
|
||||||
if name != '__weakref__' and name != '__init__' and has_doc and is_member:
|
if name != '__weakref__' and name != '__init__' and has_doc and is_member:
|
||||||
|
cls_is_owner = False
|
||||||
if what == 'class' or what == 'exception':
|
if what == 'class' or what == 'exception':
|
||||||
if sys.version_info[0] < 3:
|
if sys.version_info[0] < 3:
|
||||||
cls = getattr(obj, 'im_class', getattr(obj, '__objclass__',
|
cls = getattr(obj, 'im_class', getattr(obj, '__objclass__',
|
||||||
None))
|
None))
|
||||||
cls_is_owner = (cls and hasattr(cls, name) and
|
cls_is_owner = (cls and hasattr(cls, name) and
|
||||||
name in cls.__dict__)
|
name in cls.__dict__)
|
||||||
elif sys.version_info[1] >= 3 and hasattr(obj, '__qualname__'):
|
elif sys.version_info[1] >= 3:
|
||||||
cls_path, _, _ = obj.__qualname__.rpartition('.')
|
qualname = getattr(obj, '__qualname__', '')
|
||||||
|
cls_path, _, _ = qualname.rpartition('.')
|
||||||
if cls_path:
|
if cls_path:
|
||||||
import importlib
|
import importlib
|
||||||
import functools
|
import functools
|
||||||
|
@ -743,6 +743,13 @@ class NumpyDocstring(GoogleDocstring):
|
|||||||
r" (?P<name2>[a-zA-Z0-9_.-]+))\s*", re.X)
|
r" (?P<name2>[a-zA-Z0-9_.-]+))\s*", re.X)
|
||||||
|
|
||||||
def _parse_see_also_section(self, section):
|
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.
|
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
|
func_name1, func_name2, :meth:`func_name`, func_name3
|
||||||
|
|
||||||
"""
|
"""
|
||||||
content = self._consume_to_next_section()
|
|
||||||
items = []
|
items = []
|
||||||
|
|
||||||
def parse_item_name(text):
|
def parse_item_name(text):
|
||||||
@ -777,7 +783,8 @@ class NumpyDocstring(GoogleDocstring):
|
|||||||
rest = []
|
rest = []
|
||||||
|
|
||||||
for line in content:
|
for line in content:
|
||||||
if not line.strip(): continue
|
if not line.strip():
|
||||||
|
continue
|
||||||
|
|
||||||
m = self._name_rgx.match(line)
|
m = self._name_rgx.match(line)
|
||||||
if m and line[m.end():].strip().startswith(':'):
|
if m and line[m.end():].strip().startswith(':'):
|
||||||
@ -799,7 +806,6 @@ class NumpyDocstring(GoogleDocstring):
|
|||||||
rest.append(line.strip())
|
rest.append(line.strip())
|
||||||
push_item(current_func, rest)
|
push_item(current_func, rest)
|
||||||
|
|
||||||
|
|
||||||
if not items:
|
if not items:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
@ -278,8 +278,8 @@ class NumpyDocstringTest(BaseDocstringTest):
|
|||||||
config = Config(napoleon_use_param=False)
|
config = Config(napoleon_use_param=False)
|
||||||
actual = str(NumpyDocstring(textwrap.dedent(docstring), config))
|
actual = str(NumpyDocstring(textwrap.dedent(docstring), config))
|
||||||
expected = textwrap.dedent("""
|
expected = textwrap.dedent("""
|
||||||
:Parameters: **param1** (:class:`MyClass <name.space.MyClass>` instance)
|
:Parameters: **param1** (:class:`MyClass <name.space.MyClass>` instance)
|
||||||
""")
|
""")
|
||||||
self.assertEqual(expected, actual)
|
self.assertEqual(expected, actual)
|
||||||
|
|
||||||
config = Config(napoleon_use_param=True)
|
config = Config(napoleon_use_param=True)
|
||||||
@ -348,7 +348,8 @@ numpy.multivariate_normal(mean, cov, shape=None, spam=None)
|
|||||||
|
|
||||||
config = Config()
|
config = Config()
|
||||||
app = Mock()
|
app = Mock()
|
||||||
actual = str(NumpyDocstring(textwrap.dedent(docstring), config, app, "method"))
|
actual = str(NumpyDocstring(textwrap.dedent(docstring),
|
||||||
|
config, app, "method"))
|
||||||
|
|
||||||
expected = """
|
expected = """
|
||||||
numpy.multivariate_normal(mean, cov, shape=None, spam=None)
|
numpy.multivariate_normal(mean, cov, shape=None, spam=None)
|
||||||
|
Loading…
Reference in New Issue
Block a user