diff --git a/sphinx/builders/linkcheck.py b/sphinx/builders/linkcheck.py index c8fc040a6f1..9610b29320f 100644 --- a/sphinx/builders/linkcheck.py +++ b/sphinx/builders/linkcheck.py @@ -383,7 +383,10 @@ def check(docname: str) -> Tuple[str, str, int]: for doc_matcher in self.documents_exclude: if doc_matcher.match(docname): - info = f'{docname} matched {doc_matcher} from linkcheck_exclude_documents' + info = ( + f'{docname} matched {doc_matcher.pattern} from ' + 'linkcheck_exclude_documents' + ) return 'ignored', info, 0 if len(uri) == 0 or uri.startswith(('#', 'mailto:', 'tel:')): diff --git a/tests/test_build_linkcheck.py b/tests/test_build_linkcheck.py index 0520fb016a7..36250217ff9 100644 --- a/tests/test_build_linkcheck.py +++ b/tests/test_build_linkcheck.py @@ -631,7 +631,9 @@ def test_get_after_head_raises_connection_error(app): def test_linkcheck_exclude_documents(app): app.build() + ignore_reg = re.compile('.* matched .* from linkcheck_exclude_documents') with open(app.outdir / 'output.json') as fp: for record in fp: content = json.loads(record) assert content['status'] == 'ignored' + assert ignore_reg.match(content['info'])