summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeewis <keewis@posteo.de>2020-08-04 11:06:59 +0200
committerKeewis <keewis@posteo.de>2020-08-04 11:06:59 +0200
commit2e3e22ee03f7093f62c53cab8efe0d21e79d2c14 (patch)
treee38d48fbb59da6153d4742a2bc79a96cbb964634
parenta721631a541db298f7f9807c9db8433e928cb20b (diff)
downloadsphinx-git-2e3e22ee03f7093f62c53cab8efe0d21e79d2c14.tar.gz
apply the type preprocessor only after the check for prefer_type
-rw-r--r--sphinx/ext/napoleon/docstring.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/sphinx/ext/napoleon/docstring.py b/sphinx/ext/napoleon/docstring.py
index 95fb1e538..a41e9fdd4 100644
--- a/sphinx/ext/napoleon/docstring.py
+++ b/sphinx/ext/napoleon/docstring.py
@@ -1067,6 +1067,10 @@ class NumpyDocstring(GoogleDocstring):
_name, _type = line, ''
_name, _type = _name.strip(), _type.strip()
_name = self._escape_args_and_kwargs(_name)
+
+ if prefer_type and not _type:
+ _type, _name = _name, _type
+
if self._config.napoleon_use_param:
_type = _convert_numpy_type_spec(
_type,
@@ -1074,8 +1078,6 @@ class NumpyDocstring(GoogleDocstring):
translations=self._config.napoleon_type_aliases or {},
)
- if prefer_type and not _type:
- _type, _name = _name, _type
indent = self._get_indent(line) + 1
_desc = self._dedent(self._consume_indented_block(indent))
_desc = self.__class__(_desc, self._config).lines()