From 078aaf5f13e01b99619763e4f4eae6665ec2da26 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Fri, 30 Oct 2020 00:51:47 +0900 Subject: [PATCH 1/2] napoleon: Remove unused function --- sphinx/ext/napoleon/docstring.py | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/sphinx/ext/napoleon/docstring.py b/sphinx/ext/napoleon/docstring.py index b5c34a47990..20d9e1b9e1d 100644 --- a/sphinx/ext/napoleon/docstring.py +++ b/sphinx/ext/napoleon/docstring.py @@ -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: From 0b200d82fd48cf60a51648a9a67eec77296cb61b Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Fri, 30 Oct 2020 00:53:59 +0900 Subject: [PATCH 2/2] napoleon: simplify seealso transformation --- sphinx/ext/napoleon/docstring.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/sphinx/ext/napoleon/docstring.py b/sphinx/ext/napoleon/docstring.py index 20d9e1b9e1d..bcd2d242646 100644 --- a/sphinx/ext/napoleon/docstring.py +++ b/sphinx/ext/napoleon/docstring.py @@ -1240,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]