From 4ca3afeb58afb5b0c6d1a26a9b09f0c288df2f6f Mon Sep 17 00:00:00 2001 From: William Lachance Date: Tue, 11 Feb 2025 23:04:34 -0500 Subject: [PATCH] changes entry, test --- CHANGES.rst | 2 ++ tests/roots/test-search/index.rst | 4 ++++ tests/test_search.py | 5 ++++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index 23ace2d3b..425923c01 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -36,6 +36,8 @@ Features added * #13146: Napoleon: Unify the type preprocessing logic to allow Google-style docstrings to use the optional and default keywords. Patch by Chris Barrick. +* #11280: Add ability to skip a particular section using the `no-search` class. + Patch by Will Lachance. Bugs fixed ---------- diff --git a/tests/roots/test-search/index.rst b/tests/roots/test-search/index.rst index fc2298b5a..b38fd0271 100644 --- a/tests/roots/test-search/index.rst +++ b/tests/roots/test-search/index.rst @@ -17,6 +17,10 @@ textinheading International +.. tip:: + :class: no-search + bat cat + .. toctree:: tocitem diff --git a/tests/test_search.py b/tests/test_search.py index 600f66cb9..ac20bc30e 100644 --- a/tests/test_search.py +++ b/tests/test_search.py @@ -396,10 +396,13 @@ def test_nosearch(app): app.build() index = load_searchindex(app.outdir / 'searchindex.js') assert index['docnames'] == ['index', 'nosearch', 'tocitem'] + # latex is in 'nosearch.rst', and nowhere else assert 'latex' not in index['terms'] - assert 'bat' in index['terms'] + # cat is in 'index.rst' but is marked with the 'no-search' class + assert 'cat' not in index['terms'] # bat is indexed from 'index.rst' and 'tocitem.rst' (document IDs 0, 2), and # not from 'nosearch.rst' (document ID 1) + assert 'bat' in index['terms'] assert index['terms']['bat'] == [0, 2]