Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -575,3 +575,8 @@
'<meta property="og:image:width" content="200">',
'<meta property="og:image:height" content="200">',
)

# Options to adjust search results sorting
# ----------------------------------------

html_search_scorer = "search_scorer.js"
34 changes: 34 additions & 0 deletions Doc/search_scorer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
var Scorer = {
score: function (result) {
let [docname, title, anchor, descr, score, filename] = result;

// boost the score of built-in functions and types
const builtinPages = ["library/stdtypes", "library/functions"];
if (builtinPages.includes(docname)) {
score += 7;
}

return score;
},

// all values below this line are the Sphinx defaults

// Additive scores depending on the priority of the object
// Priority is set by object domains
// (see https://www.sphinx-doc.org/en/master/extdev/domainapi.html)
objPrio: {
0: 15,
1: 5,
2: -5,
},
objPrioDefault: 0,

objNameMatch: 11, // score if object's name exactly matches search query
objPartialMatch: 6, // score if object's name contains search query

title: 15, // score if title exactly matches search query
partialTitle: 7, // score if title contains search query

term: 5, // score if a term exactly matches search query
partialTerm: 2, // score if a term contains search query
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Rearranged documentation search results to emphasize built-in types and
functions. Patch by Adam Hartz.
Loading