Skip to content

Commit

Permalink
Save search resul score to HTML element for debugging (#10718)
Browse files Browse the repository at this point in the history
Co-authored-by: Adam Turner <9087854+aa-turner@users.noreply.github.com>
  • Loading branch information
marxin and AA-Turner committed Sep 9, 2022
1 parent c5ae585 commit 454ced9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
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

0 comments on commit 454ced9

Please sign in to comment.