summaryrefslogtreecommitdiff
path: root/sphinx/themes/basic/static
diff options
context:
space:
mode:
authorAdam Turner <9087854+aa-turner@users.noreply.github.com>2022-09-23 17:27:00 +0100
committerAdam Turner <9087854+aa-turner@users.noreply.github.com>2022-09-23 17:27:00 +0100
commit56aa3412efd8ddd6fb89f56a5f352c303454ddd9 (patch)
treef7399fdaa4a78f6725a95d3538f97eee84eaddd8 /sphinx/themes/basic/static
parent2f1d92773cc6e2857c6d4a0fd30caecbbfd5d4b3 (diff)
parentef01c5b6bd84075cb6063b0ab609f6fda61e7b3a (diff)
downloadsphinx-git-56aa3412efd8ddd6fb89f56a5f352c303454ddd9.tar.gz
Merge branch '5.x'
# Conflicts: # setup.py # sphinx/__init__.py
Diffstat (limited to 'sphinx/themes/basic/static')
-rw-r--r--sphinx/themes/basic/static/searchtools.js22
1 files changed, 20 insertions, 2 deletions
diff --git a/sphinx/themes/basic/static/searchtools.js b/sphinx/themes/basic/static/searchtools.js
index e80592c14..0073f7e94 100644
--- a/sphinx/themes/basic/static/searchtools.js
+++ b/sphinx/themes/basic/static/searchtools.js
@@ -242,6 +242,7 @@ const Search = {
const docNames = Search._index.docnames;
const titles = Search._index.titles;
const allTitles = Search._index.alltitles;
+ const indexEntries = Search._index.indexentries;
// stem the search terms and add them to the correct list
const stemmer = new Stemmer();
@@ -280,12 +281,12 @@ const Search = {
const queryLower = query.toLowerCase();
for (const [title, foundTitles] of Object.entries(allTitles)) {
- if (title.includes(queryLower) && (queryLower.length >= title.length/2)) {
+ if (title.toLowerCase().includes(queryLower) && (queryLower.length >= title.length/2)) {
for (const [file, id] of foundTitles) {
let score = Math.round(100 * queryLower.length / title.length)
results.push([
docNames[file],
- titles[file],
+ `${titles[file]} > ${title}`,
id !== null ? "#" + id : "",
null,
score,
@@ -295,6 +296,23 @@ const Search = {
}
}
+ // search for explicit entries in index directives
+ for (const [entry, foundEntries] of Object.entries(indexEntries)) {
+ if (entry.includes(queryLower) && (queryLower.length >= entry.length/2)) {
+ for (const [file, id] of foundEntries) {
+ let score = Math.round(100 * queryLower.length / entry.length)
+ results.push([
+ docNames[file],
+ titles[file],
+ id ? "#" + id : "",
+ null,
+ score,
+ filenames[file],
+ ]);
+ }
+ }
+ }
+
// lookup as object
objectTerms.forEach((term) =>
results.push(...Search.performObjectSearch(term, objectTerms))