Fix usage of enable_search_shortcuts theme config value.

The option value is not properly propagated to Java script.
This commit is contained in:
marxin 2022-06-17 15:45:04 +02:00
parent c40bb7281e
commit 3a269ee590
2 changed files with 21 additions and 1 deletions

View File

@ -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'}},
};

View File

@ -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