Skip to content

Commit

Permalink
Merge pull request #8202 from tk0miya/8190_autodoc-process-docstring-…
Browse files Browse the repository at this point in the history
…without_ending_blankline

Fix #8190: autodoc: parse error for docstring w/o ending blank lines
  • Loading branch information
tk0miya committed Sep 20, 2020
2 parents 3c017dc + b454d4e commit 28a7040
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGES
Expand Up @@ -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,
Expand Down
5 changes: 5 additions & 0 deletions sphinx/ext/autodoc/__init__.py
Expand Up @@ -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:
Expand Down
3 changes: 2 additions & 1 deletion tests/test_ext_autodoc_events.py
Expand Up @@ -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',
'',
]


Expand Down

0 comments on commit 28a7040

Please sign in to comment.