From 2df385e96c23b8267f7f3b7c38bea7bbe3ec5921 Mon Sep 17 00:00:00 2001 From: Mateusz Lapsa-Malawski Date: Fri, 7 Aug 2020 18:19:22 +0100 Subject: [PATCH 1/3] Synchronise word length between python stemmer and javascript stemmer. Python rejects words shorter then 3 while javascript allows user to search fo them. --- sphinx/search/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sphinx/search/__init__.py b/sphinx/search/__init__.py index 5413957a0..4fd566eeb 100644 --- a/sphinx/search/__init__.py +++ b/sphinx/search/__init__.py @@ -112,7 +112,7 @@ var Stemmer = function() { len(word) == 0 or not ( ((len(word) < 3) and (12353 < ord(word[0]) < 12436)) or (ord(word[0]) < 256 and ( - len(word) < 3 or word in self.stopwords + word in self.stopwords )))) From 7aa52e658cc21c0c758b768806d6d8e3c97e1ba5 Mon Sep 17 00:00:00 2001 From: Mateusz Lapsa-Malawski Date: Fri, 7 Aug 2020 19:22:17 +0100 Subject: [PATCH 2/3] update tests --- tests/test_search.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/test_search.py b/tests/test_search.py index a4cefbc67..738b1c86f 100644 --- a/tests/test_search.py +++ b/tests/test_search.py @@ -143,6 +143,7 @@ def test_IndexBuilder(): assert index._titles == {'docname': 'title', 'docname2': 'title2'} assert index._filenames == {'docname': 'filename', 'docname2': 'filename2'} assert index._mapping == { + 'ar': {'docname', 'docname2'}, 'fermion': {'docname', 'docname2'}, 'comment': {'docname', 'docname2'}, 'non': {'docname', 'docname2'}, @@ -161,7 +162,8 @@ def test_IndexBuilder(): 'objects': {'': {'objdispname': (0, 0, 1, '#anchor')}}, 'objnames': {0: ('dummy', 'objtype', 'objtype')}, 'objtypes': {0: 'dummy:objtype'}, - 'terms': {'comment': [0, 1], + 'terms': {'ar': [0, 1], + 'comment': [0, 1], 'fermion': [0, 1], 'index': [0, 1], 'non': [0, 1], @@ -197,6 +199,7 @@ def test_IndexBuilder(): assert index._titles == {'docname2': 'title2'} assert index._filenames == {'docname2': 'filename2'} assert index._mapping == { + 'ar': {'docname2'}, 'fermion': {'docname2'}, 'comment': {'docname2'}, 'non': {'docname2'}, @@ -215,7 +218,8 @@ def test_IndexBuilder(): 'objects': {}, 'objnames': {0: ('dummy', 'objtype', 'objtype')}, 'objtypes': {0: 'dummy:objtype'}, - 'terms': {'comment': 0, + 'terms': {'ar': 0, + 'comment': 0, 'fermion': 0, 'index': 0, 'non': 0, @@ -261,4 +265,3 @@ def test_nosearch(app): assert index['docnames'] == ['index', 'nosearch', 'tocitem'] assert 'latex' not in index['terms'] assert 'zfs' in index['terms'] - assert index['terms']['zfs'] == 0 # zfs on nosearch.rst is not registered to index From 2aa54e54f54d76b39770f6075dad822377b1c7b7 Mon Sep 17 00:00:00 2001 From: Mateusz Lapsa-Malawski Date: Fri, 7 Aug 2020 19:30:12 +0100 Subject: [PATCH 3/3] improve test_nosearch --- tests/test_search.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_search.py b/tests/test_search.py index 738b1c86f..72eb39a0a 100644 --- a/tests/test_search.py +++ b/tests/test_search.py @@ -265,3 +265,4 @@ def test_nosearch(app): assert index['docnames'] == ['index', 'nosearch', 'tocitem'] assert 'latex' not in index['terms'] assert 'zfs' in index['terms'] + assert index['terms']['zfs'] == [] # zfs on nosearch.rst is not registered to index