diff --git a/CHANGES b/CHANGES index fde89109821..c8de2d7e6b9 100644 --- a/CHANGES +++ b/CHANGES @@ -19,6 +19,8 @@ Bugs fixed * #8085: i18n: Add support for having single text domain * #8143: autodoc: AttributeError is raised when False value is passed to autodoc_default_options +* #8190: autodoc: parsing error is raised if some extension replaces docstring + by string not ending with blank lines * #8093: The highlight warning has wrong location in some builders (LaTeX, singlehtml and so on) diff --git a/sphinx/ext/autodoc/__init__.py b/sphinx/ext/autodoc/__init__.py index ed02c2c9087..23fb43a4d81 100644 --- a/sphinx/ext/autodoc/__init__.py +++ b/sphinx/ext/autodoc/__init__.py @@ -535,6 +535,11 @@ def process_doc(self, docstrings: List[List[str]]) -> Iterator[str]: self.env.app.emit('autodoc-process-docstring', self.objtype, self.fullname, self.object, self.options, docstringlines) + + if docstringlines and docstringlines[-1] != '': + # append a blank line to the end of the docstring + docstringlines.append('') + yield from docstringlines def get_sourcename(self) -> str: diff --git a/tests/test_ext_autodoc_events.py b/tests/test_ext_autodoc_events.py index 4e8348abc46..7ddc952ab38 100644 --- a/tests/test_ext_autodoc_events.py +++ b/tests/test_ext_autodoc_events.py @@ -28,7 +28,8 @@ def on_process_docstring(app, what, name, obj, options, lines): '.. py:function:: func()', ' :module: target.process_docstring', '', - ' my docstring' + ' my docstring', + '', ]