Skip to content
Open
Show file tree
Hide file tree
Changes from all 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 @@ -577,6 +577,11 @@
r'https://unix.org/version2/whatsnew/lp64_wp.html',
]

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

html_search_scorer = "tools/static/search_scorer.js"


# Options for sphinx.ext.extlinks
# -------------------------------
Expand Down
40 changes: 40 additions & 0 deletions Doc/tools/static/search_scorer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
var Scorer = {
Comment thread
StanFromIreland marked this conversation as resolved.
score: function (result) {
let [docname, title, anchor, descr, score, filename] = result;

// boost the score of built-in functions and types
const builtinPages = [
Comment thread
StanFromIreland marked this conversation as resolved.
"builtins/constants",
"builtins/exceptions",
"builtins/functions",
"builtins/stdtypes",
];
if (builtinPages.includes(docname)) {
score += 7;
Comment thread
StanFromIreland marked this conversation as resolved.
}

return score;
},

Comment thread
StanFromIreland marked this conversation as resolved.
// all values below this line are the Sphinx defaults
// (see https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-html_search_scorer)

// 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