Fix numbering section at singlehtml mode does not work for nested toctree

This commit is contained in:
tk0miya 2014-08-18 22:06:30 +09:00
parent ba072ab903
commit 14107fd5de
4 changed files with 15 additions and 6 deletions

View File

@ -201,6 +201,7 @@ def inline_all_toctrees(builder, docnameset, docname, tree, colorfunc):
sof = addnodes.start_of_file(docname=includefile) sof = addnodes.start_of_file(docname=includefile)
sof.children = subtree.children sof.children = subtree.children
for sectionnode in sof.traverse(nodes.section): for sectionnode in sof.traverse(nodes.section):
if 'docname' not in sectionnode:
sectionnode['docname'] = includefile sectionnode['docname'] = includefile
newnodes.append(sof) newnodes.append(sof)
toctreenode.parent.replace(toctreenode, newnodes) toctreenode.parent.replace(toctreenode, newnodes)

View File

@ -11,10 +11,9 @@ Bar A
should be 2.1 should be 2.1
Bar A1 .. toctree::
------
should be 2.1.1 baz
Bar B Bar B
===== =====

View File

@ -0,0 +1,5 @@
Baz A
-----
should be 2.1.1

View File

@ -395,10 +395,12 @@ def test_tocdepth(app):
'bar.html': [ 'bar.html': [
(".//h1", '2. Bar', True), (".//h1", '2. Bar', True),
(".//h2", '2.1. Bar A', True), (".//h2", '2.1. Bar A', True),
(".//h3", '2.1.1. Bar A1', True),
(".//h2", '2.2. Bar B', True), (".//h2", '2.2. Bar B', True),
(".//h3", '2.2.1. Bar B1', True), (".//h3", '2.2.1. Bar B1', True),
], ],
'baz.html': [
(".//h1", '2.1.1. Baz A', True),
],
} }
for fname, paths in iteritems(expects): for fname, paths in iteritems(expects):
@ -438,9 +440,11 @@ def test_tocdepth_singlehtml(app):
# bar.rst # bar.rst
(".//h2", '2. Bar', True), (".//h2", '2. Bar', True),
(".//h3", '2.1. Bar A', True), (".//h3", '2.1. Bar A', True),
(".//h4", '2.1.1. Bar A1', True),
(".//h3", '2.2. Bar B', True), (".//h3", '2.2. Bar B', True),
(".//h4", '2.2.1. Bar B1', True), (".//h4", '2.2.1. Bar B1', True),
# baz.rst
(".//h4", '2.1.1. Baz A', True),
], ],
} }