diff --git a/CHANGELOG.rst b/CHANGELOG.rst index fa9bed3..21dd6ad 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -20,6 +20,8 @@ Bug Fixes ^^^^^^^^^ * `#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 ^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/autoapi/mappers/python/mapper.py b/autoapi/mappers/python/mapper.py index 699b4d7..64a15b3 100644 --- a/autoapi/mappers/python/mapper.py +++ b/autoapi/mappers/python/mapper.py @@ -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)