Skip to content

Commit

Permalink
Fix usage of enable_search_shortcuts theme config value.
Browse files Browse the repository at this point in the history
The option value is not properly propagated to Java script.
  • Loading branch information
marxin committed Jun 17, 2022
1 parent c40bb72 commit 3a269ee
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion sphinx/themes/basic/static/documentation_options.js_t
Expand Up @@ -10,5 +10,5 @@ var DOCUMENTATION_OPTIONS = {
SOURCELINK_SUFFIX: '{{ sourcelink_suffix }}',
NAVIGATION_WITH_KEYS: {{ 'true' if theme_navigation_with_keys|tobool else 'false'}},
SHOW_SEARCH_SUMMARY: {{ 'true' if show_search_summary else 'false' }},
ENABLE_SEARCH_SHORTCUTS: {{ 'true' if enable_search_shortcuts|tobool else 'false'}},
ENABLE_SEARCH_SHORTCUTS: {{ 'true' if theme_enable_search_shortcuts|tobool else 'false'}},
};
20 changes: 20 additions & 0 deletions tests/test_build_html.py
Expand Up @@ -1757,3 +1757,23 @@ def test_option_emphasise_placeholders_default(app, status, warning):
assert '<span class="pre">={TYPE}</span>' in content
assert '<span class="pre">={WHERE}-{COUNT}</span></span>' in content
assert '<span class="pre">{client_name}</span>' in content


@pytest.mark.sphinx('html', testroot='theming')
def test_theme_options(app, status, warning):
app.build()

result = (app.outdir / '_static' / 'documentation_options.js').read_text(encoding='utf8')
assert 'NAVIGATION_WITH_KEYS: false' in result
assert 'ENABLE_SEARCH_SHORTCUTS: true' in result


@pytest.mark.sphinx('html', testroot='theming',
confoverrides={'html_theme_options.navigation_with_keys': True,
'html_theme_options.enable_search_shortcuts': False})
def test_theme_options_with_override(app, status, warning):
app.build()

result = (app.outdir / '_static' / 'documentation_options.js').read_text(encoding='utf8')
assert 'NAVIGATION_WITH_KEYS: true' in result
assert 'ENABLE_SEARCH_SHORTCUTS: false' in result

0 comments on commit 3a269ee

Please sign in to comment.