summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2020-09-21 01:02:04 +0900
committerGitHub <noreply@github.com>2020-09-21 01:02:04 +0900
commit28a7040f7b4e042ab6ecaeec11ad6b566ed89581 (patch)
treecb715a3a29d8c7cf0ebf11f2b70abb4b5a4eeb80
parent3c017dcdee6b9f4b7f5e46b3b0ba2cebced4d4dc (diff)
parentb454d4e4b0801105ad1517289c972ca2030cedd7 (diff)
downloadsphinx-git-28a7040f7b4e042ab6ecaeec11ad6b566ed89581.tar.gz
Merge pull request #8202 from tk0miya/8190_autodoc-process-docstring-without_ending_blankline
Fix #8190: autodoc: parse error for docstring w/o ending blank lines
-rw-r--r--CHANGES2
-rw-r--r--sphinx/ext/autodoc/__init__.py5
-rw-r--r--tests/test_ext_autodoc_events.py3
3 files changed, 9 insertions, 1 deletions
diff --git a/CHANGES b/CHANGES
index 738baf341..39eafd713 100644
--- a/CHANGES
+++ b/CHANGES
@@ -25,6 +25,8 @@ Bugs fixed
* #8143: autodoc: AttributeError is raised when False value is passed to
autodoc_default_options
* #8103: autodoc: functools.cached_property is not considered as a property
+* #8190: autodoc: parsing error is raised if some extension replaces docstring
+ by string not ending with blank lines
* #8192: napoleon: description is disappeared when it contains inline literals
* #8169: LaTeX: pxjahyper loaded even when latex_engine is not platex
* #8093: The highlight warning has wrong location in some builders (LaTeX,
diff --git a/sphinx/ext/autodoc/__init__.py b/sphinx/ext/autodoc/__init__.py
index ed02c2c90..23fb43a4d 100644
--- a/sphinx/ext/autodoc/__init__.py
+++ b/sphinx/ext/autodoc/__init__.py
@@ -535,6 +535,11 @@ class Documenter:
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 4e8348abc..7ddc952ab 100644
--- a/tests/test_ext_autodoc_events.py
+++ b/tests/test_ext_autodoc_events.py
@@ -28,7 +28,8 @@ def test_process_docstring(app):
'.. py:function:: func()',
' :module: target.process_docstring',
'',
- ' my docstring'
+ ' my docstring',
+ '',
]