FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-138277: Elevate Built-in Types and Functions in Documentation Search by adqm · Pull Request #138278 · python/cpython · GitHub

Repository navigation

Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .js  (1) .py  (1) .rst  (1) All 3 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
5 changes: 5 additions & 0 deletions Doc/conf.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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
};
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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

Back | FazBrowse Home | New Git URL