diff options
author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2017-10-30 13:36:10 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-30 13:36:10 +0900 |
commit | 215be8e5bd897bba9d576e2bb957cb038bd356fb (patch) | |
tree | b417cf3feae0f9c7796bec77412ee9d597b053d6 /tests | |
parent | d7d2e823fc1a59a4c94c471b4f1dfa1501f226b4 (diff) | |
parent | c0aa0ce2d8bd96406f785dd5d225eca68b32b69b (diff) | |
download | sphinx-git-215be8e5bd897bba9d576e2bb957cb038bd356fb.tar.gz |
Merge pull request #4177 from tk0miya/improve_theme_sidebars
HTML themes can set up default sidebars through ``theme.conf``
Diffstat (limited to 'tests')
-rw-r--r-- | tests/roots/test-basic/index.rst | 3 | ||||
-rw-r--r-- | tests/roots/test-theming/test_theme/test-theme/theme.conf | 1 | ||||
-rw-r--r-- | tests/test_build_html.py | 18 | ||||
-rw-r--r-- | tests/test_theming.py | 12 |
4 files changed, 34 insertions, 0 deletions
diff --git a/tests/roots/test-basic/index.rst b/tests/roots/test-basic/index.rst index 8c4ca7d80..48407e643 100644 --- a/tests/roots/test-basic/index.rst +++ b/tests/roots/test-basic/index.rst @@ -12,6 +12,9 @@ Sphinx uses reStructuredText as its markup language, and many of its strengths come from the power and straightforwardness of reStructuredText and its parsing and translating suite, the Docutils. +features +-------- + Among its features are the following: * Output formats: HTML (including derivative formats such as HTML Help, Epub diff --git a/tests/roots/test-theming/test_theme/test-theme/theme.conf b/tests/roots/test-theming/test_theme/test-theme/theme.conf index 0d8403f0b..b7518bc9c 100644 --- a/tests/roots/test-theming/test_theme/test-theme/theme.conf +++ b/tests/roots/test-theming/test_theme/test-theme/theme.conf @@ -1,2 +1,3 @@ [theme] inherit = classic +sidebars = globaltoc.html, searchbox.html diff --git a/tests/test_build_html.py b/tests/test_build_html.py index ceeb5f01c..5eaccb2bb 100644 --- a/tests/test_build_html.py +++ b/tests/test_build_html.py @@ -1245,3 +1245,21 @@ def test_html_remote_images(app, status, warning): assert ('<img alt="https://www.python.org/static/img/python-logo.png" ' 'src="https://www.python.org/static/img/python-logo.png" />' in result) assert not (app.outdir / 'python-logo.png').exists() + + +@pytest.mark.sphinx('html', testroot='basic') +def test_html_sidebar(app, status, warning): + app.builder.build_all() + result = (app.outdir / 'index.html').text(encoding='utf8') + assert '<h3><a href="#">Table Of Contents</a></h3>' in result + assert '<h3>Related Topics</h3>' in result + assert '<h3>This Page</h3>' in result + assert '<h3>Quick search</h3>' in result + + app.config.html_sidebars = {'**': []} + app.builder.build_all() + result = (app.outdir / 'index.html').text(encoding='utf8') + assert '<h3><a href="#">Table Of Contents</a></h3>' not in result + assert '<h3>Related Topics</h3>' not in result + assert '<h3>This Page</h3>' not in result + assert '<h3>Quick search</h3>' not in result diff --git a/tests/test_theming.py b/tests/test_theming.py index 408a6503f..4a6b8c956 100644 --- a/tests/test_theming.py +++ b/tests/test_theming.py @@ -95,3 +95,15 @@ def test_double_inheriting_theme(app, status, warning): def test_nested_zipped_theme(app, status, warning): assert app.builder.theme.name == 'child' app.build() # => not raises TemplateNotFound + + +@pytest.mark.sphinx(testroot='theming') +def test_theme_sidebars(app, status, warning): + app.build() + + # test-theme specifies globaltoc and searchbox as default sidebars + result = (app.outdir / 'index.html').text(encoding='utf8') + assert '<h3><a href="#">Table Of Contents</a></h3>' in result + assert '<h3>Related Topics</h3>' not in result + assert '<h3>This Page</h3>' not in result + assert '<h3>Quick search</h3>' in result |