mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Don't display 'replaceable hardcoded link' when link has a slash (#10137)
This commit is contained in:
@@ -72,7 +72,11 @@ class ExternalLinksChecker(SphinxPostTransform):
|
||||
uri_pattern = re.compile(re.escape(base_uri).replace('%s', '(?P<value>.+)'))
|
||||
|
||||
match = uri_pattern.match(uri)
|
||||
if match and match.groupdict().get('value'):
|
||||
if (
|
||||
match and
|
||||
match.groupdict().get('value') and
|
||||
'/' not in match.groupdict()['value']
|
||||
):
|
||||
# build a replacement suggestion
|
||||
msg = __('hardcoded link %r could be replaced by an extlink '
|
||||
'(try using %r instead)')
|
||||
|
@@ -17,6 +17,8 @@ https://github.com/octocat
|
||||
|
||||
`replaceable link`_
|
||||
|
||||
`non replaceable link <https://github.com/sphinx-doc/sphinx/pulls>`_
|
||||
|
||||
.. hyperlinks
|
||||
|
||||
.. _replaceable link: https://github.com/octocat
|
||||
|
@@ -28,6 +28,7 @@ def test_all_replacements_suggested_if_multiple_replacements_possible(app, warni
|
||||
app.build()
|
||||
warning_output = warning.getvalue()
|
||||
# there should be six warnings for replaceable URLs, three pairs per link
|
||||
assert warning_output.count("WARNING: hardcoded link") == 6
|
||||
message = (
|
||||
"index.rst:%d: WARNING: hardcoded link 'https://github.com/octocat' "
|
||||
"could be replaced by an extlink (try using '%s' instead)"
|
||||
|
Reference in New Issue
Block a user