From 77cee67f1155a5f869e2f47d834a86f650891807 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Sun, 25 Sep 2022 19:55:15 +0100 Subject: [PATCH] Define extra indent as a class attribute --- sphinx/ext/autodoc/__init__.py | 3 ++- sphinx/ext/autosummary/__init__.py | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/sphinx/ext/autodoc/__init__.py b/sphinx/ext/autodoc/__init__.py index c6088f45d23..93df64bb14a 100644 --- a/sphinx/ext/autodoc/__init__.py +++ b/sphinx/ext/autodoc/__init__.py @@ -961,6 +961,7 @@ class ModuleDocumenter(Documenter): objtype = 'module' content_indent = '' titles_allowed = True + _extra_indent = ' ' option_spec: OptionSpec = { 'members': members_option, 'undoc-members': bool_option, @@ -980,7 +981,7 @@ def __init__(self, *args: Any) -> None: def add_content(self, more_content: Optional[StringList]) -> None: old_indent = self.indent - self.indent += ' ' + self.indent += self._extra_indent super().add_content(None) self.indent = old_indent if more_content: diff --git a/sphinx/ext/autosummary/__init__.py b/sphinx/ext/autosummary/__init__.py index ac60216b0a0..f462a5e5ddc 100644 --- a/sphinx/ext/autosummary/__init__.py +++ b/sphinx/ext/autosummary/__init__.py @@ -371,6 +371,9 @@ def get_items(self, names: List[str]) -> List[Tuple[str, str, str, str]]: # -- Grab the summary + # bodge for ModuleDocumenter + documenter._extra_indent = '' # type: ignore[attr-defined] + documenter.add_content(None) summary = extract_summary(self.bridge.result.data[:], self.state.document)