Skip to content

Commit

Permalink
intersphinx role, simplify role_name check
Browse files Browse the repository at this point in the history
Co-authored-by: Takeshi KOMIYA <i.tkomiya@gmail.com>
  • Loading branch information
jakobandersen and tk0miya committed Jan 16, 2022
1 parent 6ee0ecb commit 5d595ec
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions sphinx/ext/intersphinx.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ class IntersphinxDispatcher(CustomReSTDispatcher):

def role(self, role_name: str, language_module: ModuleType, lineno: int, reporter: Reporter
) -> Tuple[RoleFunction, List[system_message]]:
if len(role_name) > 9 and role_name.startswith('external') and role_name[8] in ':+':
if len(role_name) > 9 and role_name.startswith(('external:', 'external+')):
return IntersphinxRole(role_name), []
else:
return super().role(role_name, language_module, lineno, reporter)
Expand Down Expand Up @@ -525,7 +525,8 @@ def get_inventory_and_name_suffix(self, name: str) -> Tuple[Optional[str], str]:
# or we look in all inventories, i.e.,
# :external:role: or
# :external:domain:role:
return IntersphinxRole._re_inv_ref.fullmatch(name, 8).group(2, 3)
inv, suffix = IntersphinxRole._re_inv_ref.fullmatch(name, 8).group(2, 3)
return inv, suffix

def get_role_name(self, name: str) -> Optional[Tuple[str, str]]:
names = name.split(':')
Expand Down

0 comments on commit 5d595ec

Please sign in to comment.