Skip to content

Commit

Permalink
Merge pull request #8351 from sphinx-doc/cleanup_napoleon
Browse files Browse the repository at this point in the history
Cleanup napoleon
  • Loading branch information
tk0miya committed Nov 1, 2020
2 parents 73f538d + 0b200d8 commit 4c2076b
Showing 1 changed file with 3 additions and 23 deletions.
26 changes: 3 additions & 23 deletions sphinx/ext/napoleon/docstring.py
Expand Up @@ -1193,25 +1193,6 @@ def push_item(name: str, rest: List[str]) -> None:
items.append((name, list(rest), role))
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):
translations = self._config.napoleon_type_aliases
if role is not None or not translations:
Expand Down Expand Up @@ -1264,14 +1245,13 @@ def translate(func, description, role):
for func, description, role in items
]

func_role = 'obj'
lines = [] # type: List[str]
last_had_desc = True
for func, desc, role in items:
for name, desc, role in items:
if role:
link = ':%s:`%s`' % (role, func)
link = ':%s:`%s`' % (role, name)
else:
link = ':%s:`%s`' % (func_role, func)
link = ':obj:`%s`' % name
if desc or last_had_desc:
lines += ['']
lines += [link]
Expand Down

0 comments on commit 4c2076b

Please sign in to comment.