Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

register custom autosummary get_documenter functions #8038

Merged
merged 11 commits into from Aug 7, 2020
11 changes: 10 additions & 1 deletion sphinx/ext/autosummary/__init__.py
Expand Up @@ -298,6 +298,15 @@ def import_by_name(self, name: str, prefixes: List[str]) -> Tuple[str, Any, Any,

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)
keewis marked this conversation as resolved.
Show resolved Hide resolved

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), ...]``.
Expand Down Expand Up @@ -329,7 +338,7 @@ def get_items(self, names: List[str]) -> List[Tuple[str, str, str, str]]:
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,
Expand Down