Skip to content
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

Save search result score to HTML element for debugging #10718

Merged
merged 2 commits into from Sep 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES
Expand Up @@ -20,6 +20,7 @@ Features added
* #10781: Allow :rst:role:`ref` role to be used with definitions and fields.
* #10717: HTML Search: Increase priority for full title and
subtitle matches in search results
* #10718: HTML Search: Save search result score to the HTML element for debugging

Bugs fixed
----------
Expand Down
3 changes: 2 additions & 1 deletion sphinx/themes/basic/static/searchtools.js
Expand Up @@ -64,7 +64,7 @@ const _displayItem = (item, highlightTerms, searchTerms) => {
const docLinkSuffix = DOCUMENTATION_OPTIONS.LINK_SUFFIX;
const showSearchSummary = DOCUMENTATION_OPTIONS.SHOW_SEARCH_SUMMARY;

const [docName, title, anchor, descr] = item;
const [docName, title, anchor, descr, score, _filename] = item;

let listItem = document.createElement("li");
let requestUrl;
Expand All @@ -86,6 +86,7 @@ const _displayItem = (item, highlightTerms, searchTerms) => {
params.set("highlight", [...highlightTerms].join(" "));
let linkEl = listItem.appendChild(document.createElement("a"));
linkEl.href = linkUrl + "?" + params.toString() + anchor;
linkEl.dataset.score = score;
linkEl.innerHTML = title;
if (descr)
listItem.appendChild(document.createElement("span")).innerHTML =
Expand Down