mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge pull request #3518 from agjohnson/fix-singlehtml-empty-toctree
Allow empty toctree in singlehtml builder
This commit is contained in:
commit
d0384130cc
@ -968,6 +968,7 @@ class SingleFileHTMLBuilder(StandaloneHTMLBuilder):
|
|||||||
if 'includehidden' not in kwds:
|
if 'includehidden' not in kwds:
|
||||||
kwds['includehidden'] = False
|
kwds['includehidden'] = False
|
||||||
toctree = self.env.get_toctree_for(docname, self, collapse, **kwds)
|
toctree = self.env.get_toctree_for(docname, self, collapse, **kwds)
|
||||||
|
if toctree is not None:
|
||||||
self.fix_refuris(toctree)
|
self.fix_refuris(toctree)
|
||||||
return self.render_partial(toctree)['fragment']
|
return self.render_partial(toctree)['fragment']
|
||||||
|
|
||||||
|
2
tests/roots/test-toctree-empty/_templates/localtoc.html
Normal file
2
tests/roots/test-toctree-empty/_templates/localtoc.html
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
{# This will call toctree unconditionally, whether there is a local or global toc #}
|
||||||
|
{{ toctree() }}
|
6
tests/roots/test-toctree-empty/conf.py
Normal file
6
tests/roots/test-toctree-empty/conf.py
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
master_doc = 'index'
|
||||||
|
html_theme = 'classic'
|
||||||
|
exclude_patterns = ['_build']
|
||||||
|
templates_path = ['_templates']
|
4
tests/roots/test-toctree-empty/index.rst
Normal file
4
tests/roots/test-toctree-empty/index.rst
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
test-toctree-empty
|
||||||
|
==================
|
||||||
|
|
||||||
|
.. toctree::
|
@ -26,3 +26,12 @@ def test_relations(app, status, warning):
|
|||||||
assert app.builder.relations['qux/qux_1'] == ['qux/index', 'qux/index', 'qux/qux_2']
|
assert app.builder.relations['qux/qux_1'] == ['qux/index', 'qux/index', 'qux/qux_2']
|
||||||
assert app.builder.relations['qux/qux_2'] == ['qux/index', 'qux/qux_1', None]
|
assert app.builder.relations['qux/qux_2'] == ['qux/index', 'qux/qux_1', None]
|
||||||
assert 'quux' not in app.builder.relations
|
assert 'quux' not in app.builder.relations
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.sphinx('singlehtml', testroot='toctree-empty')
|
||||||
|
def test_singlehtml_toctree(app, status, warning):
|
||||||
|
app.builder.build_all()
|
||||||
|
try:
|
||||||
|
app.builder._get_local_toctree('index')
|
||||||
|
except AttributeError:
|
||||||
|
pytest.fail('Unexpected AttributeError in app.builder.fix_refuris')
|
||||||
|
Loading…
Reference in New Issue
Block a user