mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
合并 birkenfeld/sphinx 到 default
This commit is contained in:
commit
96463fbf0c
@ -355,13 +355,21 @@ def _skip_member(app, what, name, obj, skip, options):
|
||||
qualname = getattr(obj, '__qualname__', '')
|
||||
cls_path, _, _ = qualname.rpartition('.')
|
||||
if cls_path:
|
||||
import importlib
|
||||
import functools
|
||||
try:
|
||||
if '.' in cls_path:
|
||||
import importlib
|
||||
import functools
|
||||
|
||||
mod = importlib.import_module(obj.__module__)
|
||||
cls = functools.reduce(getattr, cls_path.split('.'), mod)
|
||||
cls_is_owner = (cls and hasattr(cls, name) and
|
||||
name in cls.__dict__)
|
||||
mod = importlib.import_module(obj.__module__)
|
||||
mod_path = cls_path.split('.')
|
||||
cls = functools.reduce(getattr, mod_path, mod)
|
||||
else:
|
||||
cls = obj.__globals__[cls_path]
|
||||
except:
|
||||
cls_is_owner = False
|
||||
else:
|
||||
cls_is_owner = (cls and hasattr(cls, name) and
|
||||
name in cls.__dict__)
|
||||
else:
|
||||
cls_is_owner = False
|
||||
else:
|
||||
|
@ -15,6 +15,7 @@ try:
|
||||
from unittest.mock import Mock
|
||||
except ImportError:
|
||||
from mock import Mock
|
||||
from collections import namedtuple
|
||||
from sphinx.application import Sphinx
|
||||
from sphinx.ext.napoleon import (_process_docstring, _skip_member, Config,
|
||||
setup)
|
||||
@ -70,6 +71,8 @@ class SampleError(Exception):
|
||||
def __special_undoc__(self):
|
||||
pass
|
||||
|
||||
SampleNamedTuple = namedtuple('SampleNamedTuple', 'user_id block_type def_id')
|
||||
|
||||
|
||||
class ProcessDocstringTest(TestCase):
|
||||
def test_modify_in_place(self):
|
||||
@ -137,6 +140,11 @@ class SkipMemberTest(TestCase):
|
||||
self.assertEqual(skip, _skip_member(app, what, member, obj, skip,
|
||||
Mock()))
|
||||
|
||||
def test_namedtuple(self):
|
||||
self.assertSkip('class', '_asdict',
|
||||
SampleNamedTuple._asdict, False,
|
||||
'napoleon_include_private_with_doc')
|
||||
|
||||
def test_class_private_doc(self):
|
||||
self.assertSkip('class', '_private_doc',
|
||||
SampleClass._private_doc, False,
|
||||
|
Loading…
Reference in New Issue
Block a user