mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge pull request #5050 from tk0miya/5048_numbered_toctree
Fix #5048: crashed with numbered toctree
This commit is contained in:
commit
738198022c
1
CHANGES
1
CHANGES
@ -21,6 +21,7 @@ Bugs fixed
|
||||
* #5016: crashed when recommonmark.AutoStrictify is enabled
|
||||
* #5022: latex: crashed with docutils package provided by Debian/Ubuntu
|
||||
* #5009: latex: a label for table is vanished if table does not have a caption
|
||||
* #5048: crashed with numbered toctree
|
||||
|
||||
Testing
|
||||
--------
|
||||
|
@ -165,13 +165,14 @@ class TocTreeCollector(EnvironmentCollector):
|
||||
elif isinstance(subnode, addnodes.compact_paragraph):
|
||||
numstack[-1] += 1
|
||||
if depth > 0:
|
||||
number = tuple(numstack)
|
||||
number = list(numstack)
|
||||
secnums[subnode[0]['anchorname']] = tuple(numstack)
|
||||
else:
|
||||
number = None
|
||||
secnums[subnode[0]['anchorname']] = number
|
||||
subnode[0]['secnumber'] = list(number)
|
||||
secnums[subnode[0]['anchorname']] = None
|
||||
subnode[0]['secnumber'] = number
|
||||
if titlenode:
|
||||
titlenode['secnumber'] = list(number)
|
||||
titlenode['secnumber'] = number
|
||||
titlenode = None
|
||||
elif isinstance(subnode, addnodes.toctree):
|
||||
_walk_toctree(subnode, depth)
|
||||
|
@ -8,6 +8,8 @@
|
||||
:copyright: Copyright 2007-2018 by the Sphinx team, see AUTHORS.
|
||||
:license: BSD, see LICENSE for details.
|
||||
"""
|
||||
import re
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
@ -35,3 +37,12 @@ def test_singlehtml_toctree(app, status, warning):
|
||||
app.builder._get_local_toctree('index')
|
||||
except AttributeError:
|
||||
pytest.fail('Unexpected AttributeError in app.builder.fix_refuris')
|
||||
|
||||
|
||||
@pytest.mark.sphinx(testroot='toctree', srcdir="numbered-toctree")
|
||||
def test_numbered_toctree(app, status, warning):
|
||||
# give argument to :numbered: option
|
||||
index = (app.srcdir / 'index.rst').text()
|
||||
index = re.sub(':numbered:.*', ':numbered: 1', index)
|
||||
(app.srcdir / 'index.rst').write_text(index, encoding='utf-8')
|
||||
app.builder.build_all()
|
||||
|
Loading…
Reference in New Issue
Block a user