summaryrefslogtreecommitdiff
path: root/sphinx/ext/napoleon/docstring.py
diff options
context:
space:
mode:
Diffstat (limited to 'sphinx/ext/napoleon/docstring.py')
-rw-r--r--sphinx/ext/napoleon/docstring.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/sphinx/ext/napoleon/docstring.py b/sphinx/ext/napoleon/docstring.py
index b5c34a479..90f7ade52 100644
--- a/sphinx/ext/napoleon/docstring.py
+++ b/sphinx/ext/napoleon/docstring.py
@@ -699,6 +699,9 @@ class GoogleDocstring:
m = self._name_rgx.match(_type)
if m and m.group('name'):
_type = m.group('name')
+ elif _xref_regex.match(_type):
+ pos = _type.find('`')
+ _type = _type[pos + 1:-1]
_type = ' ' + _type if _type else ''
_desc = self._strip_empty(_desc)
_descs = ' ' + '\n '.join(_desc) if any(_desc) else ''
@@ -1104,6 +1107,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_preprocess_types:
_type = _convert_numpy_type_spec(
_type,
@@ -1111,8 +1118,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()