File: support_old_search_indexes.diff

package info (click to toggle)
sphinx 5.3.0-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bookworm-backports, sid, trixie
  • size: 22,992 kB
  • sloc: python: 75,843; javascript: 14,166; perl: 420; makefile: 180; sh: 58; xml: 19; ansic: 1
file content (35 lines) | stat: -rw-r--r-- 1,166 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
From: Dmitry Shachnev <mitya57@debian.org>
Date: Sat, 11 Dec 2021 19:19:27 +0300
Subject: Make searchtools.js support old searchindex.js files

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.

Forwarded: not-needed
---
 sphinx/themes/basic/static/searchtools.js | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/sphinx/themes/basic/static/searchtools.js b/sphinx/themes/basic/static/searchtools.js
index e89e34d..8279279 100644
--- a/sphinx/themes/basic/static/searchtools.js
+++ b/sphinx/themes/basic/static/searchtools.js
@@ -426,11 +426,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;
   },