Fix TOC is not shown when no `:maxdepth:` for toctrees (ref: #771)

This commit is contained in:
Takeshi KOMIYA
2016-01-21 11:32:25 +09:00
parent 0f2e62db24
commit 43c77a2838
3 changed files with 25 additions and 2 deletions

View File

@@ -16,6 +16,7 @@ Bugs fixed
* #2211: Fix paragraphs in table cell doesn't work in Latex output * #2211: Fix paragraphs in table cell doesn't work in Latex output
* #2253: ``:pyobject:`` option of ``literalinclude`` directive can't detect indented * #2253: ``:pyobject:`` option of ``literalinclude`` directive can't detect indented
body block when the block starts with blank or comment lines. body block when the block starts with blank or comment lines.
* Fix TOC is not shown when no ``:maxdepth:`` for toctrees (ref: #771)
Release 1.3.4 (released Jan 12, 2016) Release 1.3.4 (released Jan 12, 2016)
===================================== =====================================

View File

@@ -97,8 +97,8 @@ class LaTeXBuilder(Builder):
self.info("processing " + targetname + "... ", nonl=1) self.info("processing " + targetname + "... ", nonl=1)
toctrees = self.env.get_doctree(docname).traverse(addnodes.toctree) toctrees = self.env.get_doctree(docname).traverse(addnodes.toctree)
if toctrees: if toctrees:
if toctrees[0].get('maxdepth'): if toctrees[0].get('maxdepth') > 0:
tocdepth = int(toctrees[0].get('maxdepth')) tocdepth = toctrees[0].get('maxdepth')
else: else:
tocdepth = None tocdepth = None
else: else:

View File

@@ -474,3 +474,25 @@ def test_toctree_maxdepth_howto(app, status, warning):
print(status.getvalue()) print(status.getvalue())
print(warning.getvalue()) print(warning.getvalue())
assert '\\setcounter{tocdepth}{2}' in result assert '\\setcounter{tocdepth}{2}' in result
@with_app(buildername='latex', testroot='toctree-maxdepth',
confoverrides={'master_doc': 'foo'})
def test_toctree_not_found(app, status, warning):
app.builder.build_all()
result = (app.outdir / 'Python.tex').text(encoding='utf8')
print(result)
print(status.getvalue())
print(warning.getvalue())
assert '\\setcounter{tocdepth}' not in result
@with_app(buildername='latex', testroot='toctree-maxdepth',
confoverrides={'master_doc': 'bar'})
def test_toctree_without_maxdepth(app, status, warning):
app.builder.build_all()
result = (app.outdir / 'Python.tex').text(encoding='utf8')
print(result)
print(status.getvalue())
print(warning.getvalue())
assert '\\setcounter{tocdepth}' not in result