Emit warning for nested numbered toctrees (refs: #3142)

This commit is contained in:
Takeshi KOMIYA 2017-01-03 01:08:27 +09:00
parent 9bba475ca9
commit 54c8c01222
3 changed files with 8 additions and 2 deletions

View File

@ -6,6 +6,7 @@ Features added
* #3241: emit latex warning if buggy titlesec (ref #3210) * #3241: emit latex warning if buggy titlesec (ref #3210)
* #3194: Refer the $MAKE environment variable to determine ``make`` command * #3194: Refer the $MAKE environment variable to determine ``make`` command
* Emit warning for nested numbered toctrees (refs: #3142)
Bugs fixed Bugs fixed
---------- ----------

View File

@ -233,6 +233,7 @@ General configuration
* ref.citation * ref.citation
* ref.doc * ref.doc
* misc.highlighting_failure * misc.highlighting_failure
* toc.secnum
* epub.unknown_project_files * epub.unknown_project_files
You can choose from these types. You can choose from these types.

View File

@ -464,10 +464,14 @@ class Toctree(EnvironmentManager):
if depth == 0: if depth == 0:
return return
for (title, ref) in toctreenode['entries']: for (title, ref) in toctreenode['entries']:
if url_re.match(ref) or ref == 'self' or ref in assigned: if url_re.match(ref) or ref == 'self':
# don't mess with those # don't mess with those
continue continue
if ref in self.tocs: elif ref in assigned:
self.env.warn_node('%s is already assigned section numbers '
'(nested numbered toctree?)' % ref,
toctreenode, type='toc', subtype='secnum')
elif ref in self.tocs:
secnums = self.toc_secnumbers[ref] = {} secnums = self.toc_secnumbers[ref] = {}
assigned.add(ref) assigned.add(ref)
_walk_toc(self.tocs[ref], secnums, depth, _walk_toc(self.tocs[ref], secnums, depth,