Repository navigation
gh-138277: Elevate Built-in Types and Functions in Documentation Search #138278
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
915e580
2b46b78
66b736c
97a8c74
7e21628
8da1ff7
2ab5a16
4624fdc
0bdf135
00edcd2
ab0b61d
4df6d89
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| var Scorer = { | ||
| score: function (result) { | ||
| let [docname, title, anchor, descr, score, filename] = result; | ||
|
|
||
| // boost the score of built-in functions and types | ||
| const builtinPages = [ | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Following #156682, builtins have been split out. Update to include? Also alphabetise these. |
||
| "library/stdtypes", | ||
| "library/functions", | ||
| "library/exceptions", | ||
| "library/constants", | ||
| ]; | ||
| if (builtinPages.includes(docname)) { | ||
| score += 7; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm curious why a value of 7? |
||
| } | ||
|
|
||
| return score; | ||
| }, | ||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add a comment clarifying these are the defaults, as per the docs.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry to be a while getting back to this. I did used to have a comment in there saying exactly this but removed it after an earlier code review comment (in 7e21628). Should I put it back?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd prefer to have it.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sounds good. I just added that comment back (along with a reference to the Sphinx docs). |
||
| // 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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use
constorletinstead ofvar?