allow registering custom get_documenter functions

This commit is contained in:
Keewis 2020-08-02 14:05:09 +02:00
parent 5e6da19f0e
commit c212f5842c
2 changed files with 9 additions and 0 deletions

View File

@ -1045,6 +1045,9 @@ class Sphinx:
logger.debug('[app] adding autodoc attrgetter: %r', (typ, getter))
self.registry.add_autodoc_attrgetter(typ, getter)
def add_autosummary_get_documenter(self, func: Callable) -> None:
self.registry.add_autosummary_get_documenter(func)
def add_search_language(self, cls: Any) -> None:
"""Register a new language for the HTML search index.

View File

@ -61,6 +61,9 @@ class SphinxComponentRegistry:
#: autodoc documenters; a dict of documenter name -> documenter class
self.documenters = {} # type: Dict[str, Type[Documenter]]
#: autosummary documenter functions
self.custom_get_documenter_funcs = [] # type: List[Callable]
#: css_files; a list of tuple of filename and attributes
self.css_files = [] # type: List[Tuple[str, Dict[str, str]]]
@ -360,6 +363,9 @@ class SphinxComponentRegistry:
attrgetter: Callable[[Any, str, Any], Any]) -> None:
self.autodoc_attrgettrs[typ] = attrgetter
def add_autosummary_get_documenter(self, func: Callable) -> None:
self.custom_get_documenter_funcs.append(func)
def add_css_files(self, filename: str, **attributes: str) -> None:
self.css_files.append((filename, attributes))