diff options
author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2019-11-14 02:23:06 +0900 |
---|---|---|
committer | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2019-11-16 18:19:31 +0900 |
commit | 66c3dd3adb909fd028a190ab9888e6d09b5ce7c7 (patch) | |
tree | 7742578f5dab17acc14f810bd533f333083221b1 /sphinx/ext/autosummary/generate.py | |
parent | ef09ea23feaf1d21faa3d5fd990a49fb14642bfa (diff) | |
download | sphinx-git-66c3dd3adb909fd028a190ab9888e6d09b5ce7c7.tar.gz |
Close #6798: autosummary: emit ``autodoc-skip-member`` event on generating stub file
Diffstat (limited to 'sphinx/ext/autosummary/generate.py')
-rw-r--r-- | sphinx/ext/autosummary/generate.py | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/sphinx/ext/autosummary/generate.py b/sphinx/ext/autosummary/generate.py index c4726f528..177d25e9d 100644 --- a/sphinx/ext/autosummary/generate.py +++ b/sphinx/ext/autosummary/generate.py @@ -138,6 +138,16 @@ def generate_autosummary_content(name: str, obj: Any, parent: Any, if not template.exists(template_name): template_name = 'autosummary/base.rst' + def skip_member(obj: Any, name: str, objtype: str) -> bool: + try: + return app.emit_firstresult('autodoc-skip-member', objtype, name, + obj, False, {}) + except Exception as exc: + logger.warning(__('autosummary: failed to determine %r to be documented.' + 'the following exception was raised:\n%s'), + name, exc, type='autosummary') + return False + def get_members(obj: Any, types: Set[str], include_public: List[str] = [], imported: bool = True) -> Tuple[List[str], List[str]]: items = [] # type: List[str] @@ -148,9 +158,10 @@ def generate_autosummary_content(name: str, obj: Any, parent: Any, continue documenter = get_documenter(app, value, obj) if documenter.objtype in types: + # skip imported members if expected if imported or getattr(value, '__module__', None) == obj.__name__: - # skip imported members if expected - items.append(name) + if not skip_member(value, name, documenter.objtype): + items.append(name) public = [x for x in items if x in include_public or not x.startswith('_')] return public, items |