Stop calling ``autodoc-process-docstring`` when docstring is empty

pull/348/head
Ashley Whetter 2 years ago
parent cd4e1fa59f
commit 517a6be383

@ -20,6 +20,8 @@ Bug Fixes
^^^^^^^^^
* `#324 <https://github.com/readthedocs/sphinx-autoapi/issues/324>`: (Python)
Fail elegantly when no source files are found.
* (Python) Stop calling ``autodoc-process-docstring`` when docstring is empty.
Works around https://github.com/sphinx-doc/sphinx/issues/10701.
Trivial/Internal Changes
^^^^^^^^^^^^^^^^^^^^^^^^

@ -394,11 +394,18 @@ class PythonSphinxMapper(SphinxMapperBase):
# or type annotations (eg classes with inheritance),
# so do this after all children have been created.
lines = obj.docstring.splitlines()
lines.append("") # Add back the trailing newline that .splitlines removes
if lines and "autodoc-process-docstring" in self.app.events.events:
self.app.emit(
"autodoc-process-docstring", cls.type, obj.name, None, None, lines
)
if lines:
# Add back the trailing newline that .splitlines removes
lines.append("")
if "autodoc-process-docstring" in self.app.events.events:
self.app.emit(
"autodoc-process-docstring",
cls.type,
obj.name,
None,
None,
lines,
)
obj.docstring = "\n".join(lines)
self._record_typehints(obj)

Loading…
Cancel
Save