add a create_documenter method wrapping get_documenter

This commit is contained in:
Keewis 2020-08-07 14:11:32 +02:00
parent 78e4499435
commit 79a2471032

View File

@ -298,6 +298,15 @@ class Autosummary(SphinxDirective):
raise exc # re-raise ImportError if instance attribute not found
def create_documenter(self, app: Sphinx, obj: Any,
parent: Any, name: str) -> "Type[Documenter]":
"""Get an autodoc.Documenter class suitable for documenting the given
object.
Wraps get_documenter and is meant as a hook for extensions.
"""
return get_documenter(app, obj, parent)
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,7 +338,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)
doccls = self.create_documenter(self.env.app, obj, parent, real_name)
documenter = doccls(self.bridge, full_name)
if not documenter.parse_name():
logger.warning(__('failed to parse name %s'), real_name,