mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge pull request #8351 from sphinx-doc/cleanup_napoleon
Cleanup napoleon
This commit is contained in:
commit
4c2076b220
@ -1193,25 +1193,6 @@ class NumpyDocstring(GoogleDocstring):
|
|||||||
items.append((name, list(rest), role))
|
items.append((name, list(rest), role))
|
||||||
del rest[:]
|
del rest[:]
|
||||||
|
|
||||||
def search_inventory(inventory, name, hint=None):
|
|
||||||
roles = list(inventory.keys())
|
|
||||||
if hint is not None:
|
|
||||||
preferred = [
|
|
||||||
role
|
|
||||||
for role in roles
|
|
||||||
if role.split(":", 1)[-1].startswith(hint)
|
|
||||||
]
|
|
||||||
roles = preferred + [role for role in roles if role not in preferred]
|
|
||||||
|
|
||||||
for role in roles:
|
|
||||||
objects = inventory[role]
|
|
||||||
found = objects.get(name, None)
|
|
||||||
if found is not None:
|
|
||||||
domain, role = role.split(":", 1)
|
|
||||||
return role
|
|
||||||
|
|
||||||
return None
|
|
||||||
|
|
||||||
def translate(func, description, role):
|
def translate(func, description, role):
|
||||||
translations = self._config.napoleon_type_aliases
|
translations = self._config.napoleon_type_aliases
|
||||||
if role is not None or not translations:
|
if role is not None or not translations:
|
||||||
@ -1264,14 +1245,13 @@ class NumpyDocstring(GoogleDocstring):
|
|||||||
for func, description, role in items
|
for func, description, role in items
|
||||||
]
|
]
|
||||||
|
|
||||||
func_role = 'obj'
|
|
||||||
lines = [] # type: List[str]
|
lines = [] # type: List[str]
|
||||||
last_had_desc = True
|
last_had_desc = True
|
||||||
for func, desc, role in items:
|
for name, desc, role in items:
|
||||||
if role:
|
if role:
|
||||||
link = ':%s:`%s`' % (role, func)
|
link = ':%s:`%s`' % (role, name)
|
||||||
else:
|
else:
|
||||||
link = ':%s:`%s`' % (func_role, func)
|
link = ':obj:`%s`' % name
|
||||||
if desc or last_had_desc:
|
if desc or last_had_desc:
|
||||||
lines += ['']
|
lines += ['']
|
||||||
lines += [link]
|
lines += [link]
|
||||||
|
Loading…
Reference in New Issue
Block a user