diff options
author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2020-04-28 01:42:37 +0900 |
---|---|---|
committer | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2020-04-28 01:42:37 +0900 |
commit | aa773cbc88e692df731c78353a1043201bcb9f91 (patch) | |
tree | 2e5fc2c4659d73333a01f2a2c1c00420d98a801f /sphinx/ext/autosummary/generate.py | |
parent | bee44bedb100d325e4e9dad681521819bd774f5f (diff) | |
parent | ba47b7055b03050ed7d7803cb0d1c7a335646ecf (diff) | |
download | sphinx-git-aa773cbc88e692df731c78353a1043201bcb9f91.tar.gz |
Merge branch '3.x'
Diffstat (limited to 'sphinx/ext/autosummary/generate.py')
-rw-r--r-- | sphinx/ext/autosummary/generate.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/sphinx/ext/autosummary/generate.py b/sphinx/ext/autosummary/generate.py index 85f491d40..acc2a2883 100644 --- a/sphinx/ext/autosummary/generate.py +++ b/sphinx/ext/autosummary/generate.py @@ -66,6 +66,7 @@ class DummyApplication: self._warncount = 0 self.warningiserror = False + self.config.add('autosummary_context', {}, True, None) self.config.init_values() def emit_firstresult(self, *args: Any) -> None: @@ -175,7 +176,7 @@ class AutosummaryRenderer: def generate_autosummary_content(name: str, obj: Any, parent: Any, template: AutosummaryRenderer, template_name: str, imported_members: bool, app: Any, - recursive: bool) -> str: + recursive: bool, context: Dict) -> str: doc = get_documenter(app, obj, parent) def skip_member(obj: Any, name: str, objtype: str) -> bool: @@ -224,6 +225,7 @@ def generate_autosummary_content(name: str, obj: Any, parent: Any, return public, items ns = {} # type: Dict[str, Any] + ns.update(context) if doc.objtype == 'module': ns['members'] = dir(obj) @@ -329,8 +331,12 @@ def generate_autosummary_docs(sources: List[str], output_dir: str = None, _warn(__('[autosummary] failed to import %r: %s') % (entry.name, e)) continue + context = {} + if app: + context.update(app.config.autosummary_context) + content = generate_autosummary_content(name, obj, parent, template, entry.template, - imported_members, app, entry.recursive) + imported_members, app, entry.recursive, context) filename = os.path.join(path, name + suffix) if os.path.isfile(filename): |