Skip to content

Commit ea8b3d3

Browse files
authored
Merge pull request #9678 from hoefling/fix-linkcheck-warnings
Don't print file extension twice in linkcheck warnings
2 parents b639b1d + 36a6fca commit ea8b3d3

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

sphinx/builders/linkcheck.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ def process_result(self, result: CheckResult) -> None:
255255
elif result.status == 'broken':
256256
if self.app.quiet or self.app.warningiserror:
257257
logger.warning(__('broken link: %s (%s)'), result.uri, result.message,
258-
location=(filename, result.lineno))
258+
location=(result.docname, result.lineno))
259259
else:
260260
logger.info(red('broken ') + result.uri + red(' - ' + result.message))
261261
self.write_entry('broken', result.docname, filename, result.lineno,
@@ -274,7 +274,7 @@ def process_result(self, result: CheckResult) -> None:
274274
linkstat['text'] = text
275275
if self.config.linkcheck_allowed_redirects:
276276
logger.warning('redirect ' + result.uri + ' - ' + text + ' to ' +
277-
result.message, location=(filename, result.lineno))
277+
result.message, location=(result.docname, result.lineno))
278278
else:
279279
logger.info(color('redirect ') + result.uri +
280280
color(' - ' + text + ' to ' + result.message))

tests/test_build_linkcheck.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ def test_linkcheck_allowed_redirects(app, warning):
305305
assert result["http://localhost:7777/path1"] == "working"
306306
assert result["http://localhost:7777/path2"] == "redirected"
307307

308-
assert ("index.rst.rst:1: WARNING: redirect http://localhost:7777/path2 - with Found to "
308+
assert ("index.rst:1: WARNING: redirect http://localhost:7777/path2 - with Found to "
309309
"http://localhost:7777/?redirected=1\n" in strip_escseq(warning.getvalue()))
310310
assert len(warning.getvalue().splitlines()) == 1
311311

0 commit comments

Comments
 (0)