mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
* allow search hits in body text that are in title of other doc #2891 * shorten lines/add line breaks #2891 * remove out-commented LoC, simplify check #2891
This commit is contained in:
committed by
Takeshi KOMIYA
parent
71a36d5b33
commit
de7c93756c
@@ -397,7 +397,8 @@ class IndexBuilder(object):
|
||||
# again, stemmer must not remove words from search index
|
||||
if not _filter(stemmed_word) and _filter(word):
|
||||
stemmed_word = word
|
||||
if stemmed_word not in self._title_mapping and _filter(stemmed_word):
|
||||
already_indexed = docname in self._title_mapping.get(stemmed_word, [])
|
||||
if _filter(stemmed_word) and not already_indexed:
|
||||
self._mapping.setdefault(stemmed_word, set()).add(docname)
|
||||
|
||||
def context_for_searchtool(self):
|
||||
|
||||
@@ -11,4 +11,10 @@ Stemmer
|
||||
=======
|
||||
|
||||
zfs
|
||||
findthisstemmedkey
|
||||
findthisstemmedkey
|
||||
|
||||
textinheading
|
||||
|
||||
.. toctree::
|
||||
|
||||
tocitem
|
||||
10
tests/roots/test-search/tocitem.rst
Normal file
10
tests/roots/test-search/tocitem.rst
Normal file
@@ -0,0 +1,10 @@
|
||||
heading 1
|
||||
=========
|
||||
|
||||
lorem ipsum
|
||||
|
||||
|
||||
textinheading
|
||||
=============
|
||||
|
||||
lorem ipsum
|
||||
@@ -105,3 +105,13 @@ def test_stemmer_does_not_remove_short_words(app, status, warning):
|
||||
def test_stemmer(app, status, warning):
|
||||
searchindex = (app.outdir / 'searchindex.js').text()
|
||||
assert 'findthisstemmedkei' in searchindex
|
||||
|
||||
|
||||
@with_app(testroot='search')
|
||||
def test_term_in_heading_and_section(app, status, warning):
|
||||
searchindex = (app.outdir / 'searchindex.js').text()
|
||||
# if search term is in the title of one doc and in the text of another
|
||||
# both documents should be a hit in the search index as a title,
|
||||
# respectively text hit
|
||||
assert 'textinhead:1' in searchindex
|
||||
assert 'textinhead:0' in searchindex
|
||||
Reference in New Issue
Block a user