Skip to content

Commit

Permalink
Merge pull request #8038 from keewis/custom-get_documenter
Browse files Browse the repository at this point in the history
register custom autosummary get_documenter functions
  • Loading branch information
tk0miya committed Aug 7, 2020
2 parents 697dff3 + b4dec34 commit f92fa64
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions sphinx/ext/autosummary/__init__.py
Expand Up @@ -298,6 +298,16 @@ 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, 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), ...]``.
Expand Down Expand Up @@ -329,8 +339,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)
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())
Expand Down

0 comments on commit f92fa64

Please sign in to comment.