diff options
author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2018-10-01 17:49:31 +0300 |
---|---|---|
committer | Aaron Carlisle <carlisle.b3d@gmail.com> | 2018-10-01 17:49:31 +0300 |
commit | ebbf3d1697c6518a3e398144610b9951bd7ab583 (patch) | |
tree | 79ea37bbd2cf5c8528c45c789d855cb79d0f80c6 /sphinx_rtd_theme/layout.html | |
parent | 310043695f75cac495f8bde089a301e53f46d6db (diff) |
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
Diffstat (limited to 'sphinx_rtd_theme/layout.html')
-rw-r--r-- | sphinx_rtd_theme/layout.html | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/sphinx_rtd_theme/layout.html b/sphinx_rtd_theme/layout.html index 82950a2..7d9a25d 100644 --- a/sphinx_rtd_theme/layout.html +++ b/sphinx_rtd_theme/layout.html @@ -188,20 +188,28 @@ {% if not embedded %} - <script type="text/javascript"> - var DOCUMENTATION_OPTIONS = { - URL_ROOT:'{{ url_root }}', - VERSION:'{{ release|e }}', - LANGUAGE:'{{ language }}', - COLLAPSE_INDEX:false, - FILE_SUFFIX:'{{ '' if no_search_suffix else file_suffix }}', - HAS_SOURCE: {{ has_source|lower }}, - SOURCELINK_SUFFIX: '{{ sourcelink_suffix }}' - }; - </script> - {%- for scriptfile in script_files %} - <script type="text/javascript" src="{{ pathto(scriptfile, 1) }}"></script> - {%- endfor %} + {# 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 #} + {% if sphinx_version >= "1.8.0" %} + <script type="text/javascript" id="documentation_options" data-url_root="{{ pathto('', 1) }}" src="{{ pathto('_static/documentation_options.js', 1) }}"></script> + {%- for scriptfile in script_files %} + {{ js_tag(scriptfile) }} + {%- endfor %} + {% else %} + <script type="text/javascript"> + var DOCUMENTATION_OPTIONS = { + URL_ROOT:'{{ url_root }}', + VERSION:'{{ release|e }}', + LANGUAGE:'{{ language }}', + COLLAPSE_INDEX:false, + FILE_SUFFIX:'{{ '' if no_search_suffix else file_suffix }}', + HAS_SOURCE: {{ has_source|lower }}, + SOURCELINK_SUFFIX: '{{ sourcelink_suffix }}' + }; + </script> + {%- for scriptfile in script_files %} + <script type="text/javascript" src="{{ pathto(scriptfile, 1) }}"></script> + {%- endfor %} + {% endif %} {% endif %} |