diff options
Diffstat (limited to 'debian/patches/support_old_search_indexes.diff')
-rw-r--r-- | debian/patches/support_old_search_indexes.diff | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/debian/patches/support_old_search_indexes.diff b/debian/patches/support_old_search_indexes.diff new file mode 100644 index 0000000..450e5e8 --- /dev/null +++ b/debian/patches/support_old_search_indexes.diff @@ -0,0 +1,48 @@ +From: Dmitry Shachnev <mitya57@debian.org> +Date: Sat, 11 Dec 2021 19:19:27 +0300 +Subject: Make searchtools.js support documentation built with old Sphinx + +Sphinx 4.3 has changed format of searchindex.js files, but in Debian +there are lots of packages built with older Sphinx, and we want to +keep them working for some time. + +Also support legacy custom search.html templates, which don't have +data-content_root attribute on the top-level element. + +Forwarded: not-needed +--- + sphinx/themes/basic/static/searchtools.js | 12 ++++++++---- + 1 file changed, 8 insertions(+), 4 deletions(-) + +diff --git a/sphinx/themes/basic/static/searchtools.js b/sphinx/themes/basic/static/searchtools.js +index 7918c3f..09d6458 100644 +--- a/sphinx/themes/basic/static/searchtools.js ++++ b/sphinx/themes/basic/static/searchtools.js +@@ -62,7 +62,8 @@ const _displayItem = (item, searchTerms, highlightTerms) => { + const docFileSuffix = DOCUMENTATION_OPTIONS.FILE_SUFFIX; + const docLinkSuffix = DOCUMENTATION_OPTIONS.LINK_SUFFIX; + const showSearchSummary = DOCUMENTATION_OPTIONS.SHOW_SEARCH_SUMMARY; +- const contentRoot = document.documentElement.dataset.content_root; ++ const contentRoot = document.documentElement.dataset.content_root ++ ?? DOCUMENTATION_OPTIONS.URL_ROOT; + + const [docName, title, anchor, descr, score, _filename] = item; + +@@ -434,11 +435,14 @@ const Search = { + filenames[match[0]], + ]); + }; +- Object.keys(objects).forEach((prefix) => ++ Object.keys(objects).forEach((prefix) => { ++ if (!(objects[prefix] instanceof Array)) { ++ objects[prefix] = Object.entries(objects[prefix]).map(([name, match]) => [...match, name]); ++ } + objects[prefix].forEach((array) => + objectSearchCallback(prefix, array) +- ) +- ); ++ ); ++ }); + return results; + }, + |