From 376e3a658ab062c7d25f4bb730745bf4f8159ff6 Mon Sep 17 00:00:00 2001 From: Christian Roth Date: Mon, 6 Dec 2021 16:40:36 +0100 Subject: [PATCH] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: François Freitag --- CHANGES | 2 +- sphinx/builders/linkcheck.py | 2 +- tests/test_build_linkcheck.py | 3 +-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/CHANGES b/CHANGES index cb1d75bea49..7c448d04bd7 100644 --- a/CHANGES +++ b/CHANGES @@ -47,7 +47,7 @@ Features added ``__all__`` attribute if :confval:`autosummary_ignore_module_all` is set to ``False``. The default behaviour is unchanged. Autogen also now supports this behavior with the ``--respect-module-all`` switch. -* #9894: linkcheck: new option`linkcheck_exclude_documents` allows to disable +* #9894: linkcheck: add option `linkcheck_exclude_documents` to disable link checking in matched documents. link check in matched documents. Bugs fixed diff --git a/sphinx/builders/linkcheck.py b/sphinx/builders/linkcheck.py index 16d46c69828..1bc1c5b01bc 100644 --- a/sphinx/builders/linkcheck.py +++ b/sphinx/builders/linkcheck.py @@ -383,7 +383,7 @@ def check(docname: str) -> Tuple[str, str, int]: for doc_matcher in self.documents_exclude: if doc_matcher.match(docname): - return 'unchecked', '', 0 + return 'ignored', f'{docname} matched {doc_matcher} from linkcheck_exclude_documents', 0 if len(uri) == 0 or uri.startswith(('#', 'mailto:', 'tel:')): return 'unchecked', '', 0 diff --git a/tests/test_build_linkcheck.py b/tests/test_build_linkcheck.py index 5e5a00c4bf4..afadc069309 100644 --- a/tests/test_build_linkcheck.py +++ b/tests/test_build_linkcheck.py @@ -629,8 +629,7 @@ def test_get_after_head_raises_connection_error(app): @pytest.mark.sphinx('linkcheck', testroot='linkcheck-documents_exclude', freshenv=True) def test_linkcheck_exclude_documents(app): - with http_server(make_redirect_handler(support_head=False)): - app.build() + app.build() with open(app.outdir / 'output.json') as fp: for record in fp: