diff options
| author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2020-08-08 01:15:20 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-08-08 01:15:20 +0900 |
| commit | f92fa6443fe6f457ab0c26d41eb229e825fda5e1 (patch) | |
| tree | 2fe2cf3aff0eec34b0cf6a1bbb410522719b1e50 /sphinx | |
| parent | 697dff31ab09625ead62e1a7ec0780126aeb07c6 (diff) | |
| parent | b4dec34ecfa36628452097911b182d0df6265e68 (diff) | |
| download | sphinx-git-f92fa6443fe6f457ab0c26d41eb229e825fda5e1.tar.gz | |
Merge pull request #8038 from keewis/custom-get_documenter
register custom autosummary get_documenter functions
Diffstat (limited to 'sphinx')
| -rw-r--r-- | sphinx/ext/autosummary/__init__.py | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/sphinx/ext/autosummary/__init__.py b/sphinx/ext/autosummary/__init__.py index 855affa95..739636d7e 100644 --- a/sphinx/ext/autosummary/__init__.py +++ b/sphinx/ext/autosummary/__init__.py @@ -298,6 +298,16 @@ class Autosummary(SphinxDirective): raise exc # re-raise ImportError if instance attribute not found + def create_documenter(self, app: Sphinx, obj: Any, + parent: Any, full_name: str) -> "Documenter": + """Get an autodoc.Documenter class suitable for documenting the given + object. + + Wraps get_documenter and is meant as a hook for extensions. + """ + doccls = get_documenter(app, obj, parent) + return doccls(self.bridge, full_name) + def get_items(self, names: List[str]) -> List[Tuple[str, str, str, str]]: """Try to import the given names, and return a list of ``[(name, signature, summary_string, real_name), ...]``. @@ -329,8 +339,7 @@ class Autosummary(SphinxDirective): full_name = modname + '::' + full_name[len(modname) + 1:] # NB. using full_name here is important, since Documenters # handle module prefixes slightly differently - doccls = get_documenter(self.env.app, obj, parent) - documenter = doccls(self.bridge, full_name) + documenter = self.create_documenter(self.env.app, obj, parent, full_name) if not documenter.parse_name(): logger.warning(__('failed to parse name %s'), real_name, location=self.get_source_info()) |
