mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix #5066: html: "relations" sidebar is not shown by default
This commit is contained in:
@@ -1230,21 +1230,50 @@ def test_html_remote_images(app, status, warning):
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='basic')
|
||||
def test_html_sidebar(app, status, warning):
|
||||
ctx = {}
|
||||
|
||||
# default for alabaster
|
||||
app.builder.build_all()
|
||||
result = (app.outdir / 'index.html').text(encoding='utf8')
|
||||
assert '<h3><a href="#">Table Of Contents</a></h3>' in result
|
||||
assert ('<div class="sphinxsidebar" role="navigation" '
|
||||
'aria-label="main navigation">' in result)
|
||||
assert '<h1 class="logo"><a href="#">Python</a></h1>' in result
|
||||
assert '<h3>Navigation</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.builder.add_sidebars('index', ctx)
|
||||
assert ctx['sidebars'] == ['about.html', 'navigation.html', 'relations.html',
|
||||
'searchbox.html', 'donate.html']
|
||||
|
||||
# only relations.html
|
||||
app.config.html_sidebars = {'**': ['relations.html']}
|
||||
app.builder.build_all()
|
||||
result = (app.outdir / 'index.html').text(encoding='utf8')
|
||||
assert ('<div class="sphinxsidebar" role="navigation" '
|
||||
'aria-label="main navigation">' in result)
|
||||
assert '<h1 class="logo"><a href="#">Python</a></h1>' not in result
|
||||
assert '<h3>Navigation</h3>' not in result
|
||||
assert '<h3>Related Topics</h3>' in result
|
||||
assert '<h3>Quick search</h3>' not in result
|
||||
|
||||
app.builder.add_sidebars('index', ctx)
|
||||
assert ctx['sidebars'] == ['relations.html']
|
||||
|
||||
# no sidebars
|
||||
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 ('<div class="sphinxsidebar" role="navigation" '
|
||||
'aria-label="main navigation">' not in result)
|
||||
assert '<h1 class="logo"><a href="#">Python</a></h1>' not in result
|
||||
assert '<h3>Navigation</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
|
||||
|
||||
app.builder.add_sidebars('index', ctx)
|
||||
assert ctx['sidebars'] == []
|
||||
|
||||
|
||||
@pytest.mark.parametrize('fname,expect', flat_dict({
|
||||
'index.html': [(".//em/a[@href='https://example.com/man.1']", "", True),
|
||||
|
||||
Reference in New Issue
Block a user