Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup napoleon #8351

Merged
merged 2 commits into from Nov 1, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 3 additions & 23 deletions sphinx/ext/napoleon/docstring.py
Expand Up @@ -1188,25 +1188,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 @@ -1259,14 +1240,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