Skip to content

Commit ebbf3d1

Browse files
tk0miyaBlendify
authored andcommitted
Fix HTML search not working with Sphinx-1.8. (#672)
* Fix HTML search not working Since Sphinx-1.7, Sphinx has exported search options as `documentation_options.js`. This starts to refer it instead of definitions of JavaScript variables. In addition, this also uses `js_tag()` function which added in 1.8 to support additional attributes for scripts (ex. async attribute). * Add code comment
1 parent 3100436 commit ebbf3d1

File tree

1 file changed

+22
-14
lines changed

1 file changed

+22
-14
lines changed

sphinx_rtd_theme/layout.html

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -188,20 +188,28 @@
188188

189189
{% if not embedded %}
190190

191-
<script type="text/javascript">
192-
var DOCUMENTATION_OPTIONS = {
193-
URL_ROOT:'{{ url_root }}',
194-
VERSION:'{{ release|e }}',
195-
LANGUAGE:'{{ language }}',
196-
COLLAPSE_INDEX:false,
197-
FILE_SUFFIX:'{{ '' if no_search_suffix else file_suffix }}',
198-
HAS_SOURCE: {{ has_source|lower }},
199-
SOURCELINK_SUFFIX: '{{ sourcelink_suffix }}'
200-
};
201-
</script>
202-
{%- for scriptfile in script_files %}
203-
<script type="text/javascript" src="{{ pathto(scriptfile, 1) }}"></script>
204-
{%- endfor %}
191+
{# XXX Sphinx 1.8.0 made this an external js-file, quick fix until we refactor the template to inherert more blocks directly from sphinx #}
192+
{% if sphinx_version >= "1.8.0" %}
193+
<script type="text/javascript" id="documentation_options" data-url_root="{{ pathto('', 1) }}" src="{{ pathto('_static/documentation_options.js', 1) }}"></script>
194+
{%- for scriptfile in script_files %}
195+
{{ js_tag(scriptfile) }}
196+
{%- endfor %}
197+
{% else %}
198+
<script type="text/javascript">
199+
var DOCUMENTATION_OPTIONS = {
200+
URL_ROOT:'{{ url_root }}',
201+
VERSION:'{{ release|e }}',
202+
LANGUAGE:'{{ language }}',
203+
COLLAPSE_INDEX:false,
204+
FILE_SUFFIX:'{{ '' if no_search_suffix else file_suffix }}',
205+
HAS_SOURCE: {{ has_source|lower }},
206+
SOURCELINK_SUFFIX: '{{ sourcelink_suffix }}'
207+
};
208+
</script>
209+
{%- for scriptfile in script_files %}
210+
<script type="text/javascript" src="{{ pathto(scriptfile, 1) }}"></script>
211+
{%- endfor %}
212+
{% endif %}
205213

206214
{% endif %}
207215

0 commit comments

Comments
 (0)