Skip to content
This repository was archived by the owner on Apr 8, 2025. It is now read-only.

Commit 8b25211

Browse files
committed
Fix compatibility with sphinx 3.5.x
1 parent 5eff860 commit 8b25211

File tree

3 files changed

+23
-7
lines changed

3 files changed

+23
-7
lines changed

docs/requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
sphinx==1.8.5
1+
sphinx==3.5.1
22
sphinx-prompt==1.1.0
33
sphinx-tabs==1.1.10
44
sphinx-rtd-theme==0.4.3
55
sphinx-notfound-page==0.3
6-
sphinx-js==2.7.1
6+
sphinx-js==3.1

sphinx_search/static/js/rtd_sphinx_search.js

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,22 @@ const debounce = (func, wait) => {
3939
return debounced;
4040
};
4141

42+
43+
/**
44+
* Wrapper around underscorejs's template function.
45+
*
46+
* This is to make it work with new and old versions.
47+
*/
48+
const render_template = (template, data) => {
49+
// pre-1.7 syntax from underscorejs.
50+
let result = $u.template(template, data);
51+
if (typeof result === 'function') {
52+
// New syntax.
53+
result = $u.template(template)(data);
54+
}
55+
return result;
56+
};
57+
4258
/**
4359
* Take an object as parameter and convert it to
4460
* url params string.
@@ -219,7 +235,7 @@ const get_section_html = (sectionData, page_link, id) => {
219235

220236
let section_id = "hit__" + id;
221237

222-
let section_html = $u.template(section_template, {
238+
let section_html = render_template(section_template, {
223239
section_link: section_link,
224240
section_id: section_id,
225241
section_subheading: section_subheading,
@@ -269,7 +285,7 @@ const get_domain_html = (domainData, page_link, id) => {
269285
let domain_id = "hit__" + id;
270286
domain_role_name = "[" + domain_role_name + "]";
271287

272-
let domain_html = $u.template(domain_template, {
288+
let domain_html = render_template(domain_template, {
273289
domain_link: domain_link,
274290
domain_id: domain_id,
275291
domain_content: domain_content,
@@ -311,7 +327,7 @@ const generateSingleResult = (resultData, projectName, id) => {
311327
if (projectName !== resultData.project) {
312328
page_title +=
313329
" " +
314-
$u.template(
330+
render_template(
315331
'<small class="rtd_ui_search_subtitle"> \
316332
(from project <%= project %>) \
317333
</small>',
@@ -323,7 +339,7 @@ const generateSingleResult = (resultData, projectName, id) => {
323339

324340
page_title += "<br>";
325341

326-
content.innerHTML += $u.template(page_link_template, {
342+
content.innerHTML += render_template(page_link_template, {
327343
page_link: page_link,
328344
page_title: page_title
329345
});

0 commit comments

Comments
 (0)