Skip to content

Commit

Permalink
apply suggestions from sphinx-doc#9800 here as well
Browse files Browse the repository at this point in the history
Signed-off-by: oleg.hoefling <oleg.hoefling@gmail.com>
  • Loading branch information
hoefling committed Nov 12, 2021
1 parent a3da80d commit f2f07a3
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions sphinx/ext/intersphinx.py
Expand Up @@ -87,7 +87,7 @@ class ExternalLinksChecker(SphinxPostTransform):
We treat each ``reference`` node without ``internal`` attribute as an external link.
"""

default_priority = 900
default_priority = 100

def run(self, **kwargs: Any) -> None:
for refnode in self.document.traverse(reference):
Expand All @@ -102,25 +102,23 @@ def check_uri(self, refnode: reference) -> None:
return

uri = refnode['refuri']
lineno = sphinx.util.nodes.get_node_line(refnode)
cache = getattr(self.app.env, 'intersphinx_cache', dict())
cache = self.app.env.intersphinx_cache

for inventory_uri, (inventory_name, size, inventory) in cache.items():
if uri.startswith(inventory_uri):
# build a replacement suggestion
replacements = find_replacements(self.app, uri)
try:
suggestion = f'try using {next(replacements)!r} instead'
location = (self.env.docname, lineno)
logger.warning(
(
__(
'hardcoded link %r could be replaced by '
'a cross-reference to %r inventory (%s)'
),
uri,
inventory_name,
suggestion,
location=location,
location=refnode,
)
except StopIteration:
pass
Expand Down

0 comments on commit f2f07a3

Please sign in to comment.