From 907e53f463d645f641c69303cb7dc239b211085d Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Fri, 16 Dec 2016 11:39:10 +0900 Subject: [PATCH 01/20] LaTeX builder: Refactor the default settings generators (refs: #3244) --- sphinx/builders/latex.py | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/sphinx/builders/latex.py b/sphinx/builders/latex.py index 7bd43a84c..e42ed7ace 100644 --- a/sphinx/builders/latex.py +++ b/sphinx/builders/latex.py @@ -268,13 +268,28 @@ def validate_config_values(app): app.config.latex_elements['postamble'] = app.config.latex_elements['footer'] +def default_latex_engine(config): + """ Better default latex_engine settings for specific languages. """ + if config.language == 'ja': + return 'platex' + else: + return 'pdflatex' + + +def default_latex_docclass(config): + """ Better default latex_docclass settings for specific languages. """ + if config.language == 'ja': + return {'manual': 'jsbook', + 'howto': 'jreport'} + else: + return {} + + def setup(app): app.add_builder(LaTeXBuilder) app.connect('builder-inited', validate_config_values) - app.add_config_value('latex_engine', - lambda self: 'pdflatex' if self.language != 'ja' else 'platex', - None, + app.add_config_value('latex_engine', default_latex_engine, None, ENUM('pdflatex', 'xelatex', 'lualatex', 'platex')) app.add_config_value('latex_documents', lambda self: [(self.master_doc, make_filename(self.project) + '.tex', @@ -297,11 +312,7 @@ def setup(app): app.add_config_value('latex_elements', {}, None) app.add_config_value('latex_additional_files', [], None) - japanese_default = {'manual': 'jsbook', - 'howto': 'jreport'} - app.add_config_value('latex_docclass', - lambda self: japanese_default if self.language == 'ja' else {}, - None) + app.add_config_value('latex_docclass', default_latex_docclass, None) # now deprecated - use latex_elements app.add_config_value('latex_preamble', '', None) From 07633a5a712a3b06c21ef35c341a606ad9b96d47 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Tue, 20 Dec 2016 18:44:33 +0900 Subject: [PATCH 02/20] Fix the warning type ``misc.highlighting_failure`` does not work --- CHANGES | 1 + sphinx/highlighting.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index c24b83655..7cc7cd809 100644 --- a/CHANGES +++ b/CHANGES @@ -17,6 +17,7 @@ Bugs fixed * #3255: In Py3.4 environment, autodoc doesn't support documentation for attributes of Enum class correctly. * #3261: ``latex_use_parts`` makes sphinx crash +* The warning type ``misc.highlighting_failure`` does not work Release 1.5.1 (released Dec 13, 2016) ===================================== diff --git a/sphinx/highlighting.py b/sphinx/highlighting.py index 4b4ba87da..198939197 100644 --- a/sphinx/highlighting.py +++ b/sphinx/highlighting.py @@ -144,7 +144,7 @@ class PygmentsBridge(object): elif warn: warn('Could not lex literal_block as "%s". ' 'Highlighting skipped.' % lang, - type='misc', subtype='higlighting_failure') + type='misc', subtype='highlighting_failure') else: raise exc hlsource = highlight(source, lexers['none'], formatter) From 01977fcb728216ba69d1a4635b1c633f3c7c4462 Mon Sep 17 00:00:00 2001 From: Dmitry Shachnev Date: Thu, 22 Dec 2016 10:36:15 +0300 Subject: [PATCH 03/20] Load non-minified JS files from sphinx.package_dir This makes the code consistent with other parts of Sphinx, and allows downstream packagers to move all static files to /usr/share. --- sphinx/search/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sphinx/search/__init__.py b/sphinx/search/__init__.py index 23dc869ee..8f2935227 100644 --- a/sphinx/search/__init__.py +++ b/sphinx/search/__init__.py @@ -414,7 +414,7 @@ class IndexBuilder(object): def get_js_stemmer_rawcode(self): if self.lang.js_stemmer_rawcode: return path.join( - path.dirname(path.abspath(__file__)), + sphinx.package_dir, 'search', 'non-minified-js', self.lang.js_stemmer_rawcode ) From 01736bb3970e0fc3d733ca6f5df24480e3545a2a Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sat, 24 Dec 2016 18:43:35 +0900 Subject: [PATCH 04/20] Fix test_latex failed if stylefiles not found (refs: #3264) --- tests/test_build_latex.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test_build_latex.py b/tests/test_build_latex.py index 8a899caa5..dfcadc6a1 100644 --- a/tests/test_build_latex.py +++ b/tests/test_build_latex.py @@ -50,7 +50,7 @@ def kpsetest(*filenames): except OSError: # no kpsewhich... either no tex distribution is installed or it is # a "strange" one -- don't bother running latex - return None + return False else: p.communicate() if p.returncode != 0: @@ -84,8 +84,8 @@ def compile_latex_document(app): def skip_if_stylefiles_notfound(testfunc): if kpsetest(*STYLEFILES) is False: - return skip_if(testfunc, - 'not running latex, the required styles do not seem to be installed') + msg = 'not running latex, the required styles do not seem to be installed' + return skip_if(True, msg)(testfunc) else: return testfunc From f65c5ee3def215c3aff3f57be6a1fa81935459b4 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sat, 24 Dec 2016 18:45:32 +0900 Subject: [PATCH 05/20] Install enum34 on testing pypy (refs: #3264) --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 1ccaa583f..110bd454f 100644 --- a/tox.ini +++ b/tox.ini @@ -10,6 +10,7 @@ deps= whoosh html5lib mock + enum34 typing setenv = SPHINX_TEST_TEMPDIR = {envdir}/testbuild @@ -43,7 +44,6 @@ commands=flake8 [testenv:py27] deps= - enum34 {[testenv]deps} [testenv:py35] From 8dcc3a259ce353fae7eb3b280f0c28e4643d63bd Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sat, 24 Dec 2016 19:30:17 +0900 Subject: [PATCH 06/20] Fix 'tox -e du12' fails (refs: #3264) --- tox.ini | 1 - 1 file changed, 1 deletion(-) diff --git a/tox.ini b/tox.ini index 110bd454f..bbdb6ff14 100644 --- a/tox.ini +++ b/tox.ini @@ -5,7 +5,6 @@ envlist=flake8,py27,py34,py35,pypy,du12,du11,du10 deps= six nose - docutils sqlalchemy whoosh html5lib From c7783e632f81d9d5e29be7baf836df7d72942453 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sat, 24 Dec 2016 22:13:10 +0900 Subject: [PATCH 07/20] Update setup.cfg (refs: #3264) --- setup.cfg | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/setup.cfg b/setup.cfg index a65719461..73ac1e746 100644 --- a/setup.cfg +++ b/setup.cfg @@ -24,6 +24,6 @@ directory = sphinx/locale/ universal = 1 [flake8] -max-line-length=95 -ignore=E113,E116,E221,E226,E241,E251,E901 -exclude=tests/*,build/*,sphinx/search/*,sphinx/pycode/pgen2/*,doc/ext/example*.py +max-line-length = 95 +ignore = E113,E116,E221,E226,E241,E251,E901 +exclude = .git,.tox,tests/*,build/*,sphinx/search/*,sphinx/pycode/pgen2/*,doc/ext/example*.py From 7ab20262ff412f8c3cd8fdbef0dd16f79d890554 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sat, 24 Dec 2016 22:23:49 +0900 Subject: [PATCH 08/20] Set PYTHONDONTWRITEBYTECODE=true on testing (refs: #3264) --- tox.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/tox.ini b/tox.ini index bbdb6ff14..e9f4951fd 100644 --- a/tox.ini +++ b/tox.ini @@ -13,6 +13,7 @@ deps= typing setenv = SPHINX_TEST_TEMPDIR = {envdir}/testbuild + PYTHONDONTWRITEBYTECODE = true commands= {envpython} -Wall tests/run.py -I py35 -m '^[tT]est' {posargs} sphinx-build -q -W -b html -d {envtmpdir}/doctrees doc {envtmpdir}/html From 866da5a8d08fd4bef127e8b11954d83fc011253b Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sat, 24 Dec 2016 23:51:30 +0900 Subject: [PATCH 09/20] Clarify test command (refs: #3264) --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index e9f4951fd..e46c0b8d8 100644 --- a/tox.ini +++ b/tox.ini @@ -15,7 +15,7 @@ setenv = SPHINX_TEST_TEMPDIR = {envdir}/testbuild PYTHONDONTWRITEBYTECODE = true commands= - {envpython} -Wall tests/run.py -I py35 -m '^[tT]est' {posargs} + {envpython} -Wall tests/run.py --ignore-files=test_autodoc_py35 -m '^[tT]est' {posargs} sphinx-build -q -W -b html -d {envtmpdir}/doctrees doc {envtmpdir}/html [testenv:pypy] From 36eab77c3d05b661782f0fbe17a99cb7505a4d89 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sat, 24 Dec 2016 13:05:35 +0900 Subject: [PATCH 10/20] Add py36 support --- .travis.yml | 5 +++-- doc/install.rst | 4 ++-- tox.ini | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 82bcb9f23..250f3cffd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,7 @@ python: - "2.7" - "3.4" - "3.5" + - "3.6" - "nightly" - "pypy" env: @@ -34,5 +35,5 @@ install: before_script: - if [[ $TRAVIS_PYTHON_VERSION != '2.6' ]]; then flake8; fi script: - - if [[ $TRAVIS_PYTHON_VERSION == '3.5' ]]; then make style-check test-async; fi - - if [[ $TRAVIS_PYTHON_VERSION != '3.5' ]]; then make test; fi + - if [[ $TRAVIS_PYTHON_VERSION == '3.6' ]]; then make style-check test-async; fi + - if [[ $TRAVIS_PYTHON_VERSION != '3.6' ]]; then make test; fi diff --git a/doc/install.rst b/doc/install.rst index b3519e1ba..2eb44b809 100644 --- a/doc/install.rst +++ b/doc/install.rst @@ -79,8 +79,8 @@ sidebar and under "Quick Links", click "Windows Installer" to download. .. note:: - Currently, Python offers two major versions, 2.x and 3.x. Sphinx 1.3 can run - under Python 2.7, 3.4, 3.5, with the recommended version being 2.7. This + Currently, Python offers two major versions, 2.x and 3.x. Sphinx 1.5 can run + under Python 2.7, 3.4, 3.5, 3.6, with the recommended version being 2.7. This chapter assumes you have installed Python 2.7. Follow the Windows installer for Python. diff --git a/tox.ini b/tox.ini index e46c0b8d8..df02121c5 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist=flake8,py27,py34,py35,pypy,du12,du11,du10 +envlist=flake8,py27,py34,py35,py36,pypy,du12,du11,du10 [testenv] deps= From 6a5ffb403e672a1aeec6813be0e4792064fb4e88 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sat, 24 Dec 2016 13:06:45 +0900 Subject: [PATCH 11/20] Reduce CI matrix --- .travis.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.travis.yml b/.travis.yml index 250f3cffd..f4e2e544d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,6 +18,16 @@ env: matrix: - DOCUTILS=0.12 - DOCUTILS=0.13.1 +matrix: + exclude: + - python: "3.4" + env: DOCUTILS=0.12 + - python: "3.5" + env: DOCUTILS=0.12 + - python: nightly + env: DOCUTILS=0.12 + - python: pypy + env: DOCUTILS=0.12 addons: apt: packages: From 934ec657d4d5b04379013b2f689c51b9e2f87008 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sat, 24 Dec 2016 13:09:23 +0900 Subject: [PATCH 12/20] Remove unsupported platform from tox.ini --- tox.ini | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/tox.ini b/tox.ini index df02121c5..e8a45f845 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist=flake8,py27,py34,py35,py36,pypy,du12,du11,du10 +envlist=flake8,py27,py34,py35,py36,pypy,du12,du11 [testenv] deps= @@ -23,11 +23,6 @@ deps= simplejson {[testenv]deps} -[testenv:du10] -deps= - docutils==0.10 - {[testenv]deps} - [testenv:du11] deps= docutils==0.11 From 4cc3c154fec15714929c65ca3649d87f1c506338 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sat, 24 Dec 2016 17:31:58 +0900 Subject: [PATCH 13/20] Refactor travis.yml --- .travis.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index f4e2e544d..09b89a7ae 100644 --- a/.travis.yml +++ b/.travis.yml @@ -42,8 +42,7 @@ install: - pip install -U pip setuptools - pip install docutils==$DOCUTILS - pip install -r test-reqs.txt -before_script: - - if [[ $TRAVIS_PYTHON_VERSION != '2.6' ]]; then flake8; fi script: - - if [[ $TRAVIS_PYTHON_VERSION == '3.6' ]]; then make style-check test-async; fi - - if [[ $TRAVIS_PYTHON_VERSION != '3.6' ]]; then make test; fi + - flake8 + - if [[ $TRAVIS_PYTHON_VERSION == '3.6' ]]; then make style-check test-async; fi + - if [[ $TRAVIS_PYTHON_VERSION != '3.6' ]]; then make test; fi From a5b15195e200297819d0118c6db21b00d06e7bb6 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sun, 25 Dec 2016 12:22:54 +0900 Subject: [PATCH 14/20] Add du13 target to tox.ini --- tox.ini | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index e8a45f845..09241c1d8 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist=flake8,py27,py34,py35,py36,pypy,du12,du11 +envlist=flake8,py27,py34,py35,py36,pypy,du13,du12,du11 [testenv] deps= @@ -33,6 +33,11 @@ deps= docutils==0.12 {[testenv]deps} +[testenv:du13] +deps= + docutils==0.13.1 + {[testenv]deps} + [testenv:flake8] deps=flake8 commands=flake8 From 5ae27f65b4be924baef24ba1287aab5ae548c437 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sat, 24 Dec 2016 15:11:04 +0900 Subject: [PATCH 15/20] Hide builtin extension on traceback --- sphinx/util/__init__.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sphinx/util/__init__.py b/sphinx/util/__init__.py index d682ad522..e650f7aa9 100644 --- a/sphinx/util/__init__.py +++ b/sphinx/util/__init__.py @@ -211,9 +211,10 @@ def save_traceback(app): modfile = getattr(extmod, '__file__', 'unknown') if isinstance(modfile, bytes): modfile = modfile.decode(fs_encoding, 'replace') - os.write(fd, ('# %s (%s) from %s\n' % ( - extname, app._extension_metadata[extname]['version'], - modfile)).encode('utf-8')) + version = app._extension_metadata[extname]['version'] + if version != 'builtin': + os.write(fd, ('# %s (%s) from %s\n' % + (extname, version, modfile)).encode('utf-8')) os.write(fd, exc_format.encode('utf-8')) os.close(fd) return path From 54cac94cdfa0f558d87dfdc5b36618aa6dda61df Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sun, 1 Jan 2017 20:07:16 +0900 Subject: [PATCH 16/20] Fix #3294: ``add_latex_package()`` make crashes non-LaTeX builders --- CHANGES | 2 ++ sphinx/application.py | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 7cc7cd809..632280ee3 100644 --- a/CHANGES +++ b/CHANGES @@ -18,6 +18,8 @@ Bugs fixed attributes of Enum class correctly. * #3261: ``latex_use_parts`` makes sphinx crash * The warning type ``misc.highlighting_failure`` does not work +* #3294: ``add_latex_package()`` make crashes non-LaTeX builders + Release 1.5.1 (released Dec 13, 2016) ===================================== diff --git a/sphinx/application.py b/sphinx/application.py index 00661aa61..f3bc381bc 100644 --- a/sphinx/application.py +++ b/sphinx/application.py @@ -806,7 +806,8 @@ class Sphinx(object): def add_latex_package(self, packagename, options=None): self.debug('[app] adding latex package: %r', packagename) - self.builder.usepackages.append((packagename, options)) + if hasattr(self.builder, 'usepackages'): # only for LaTeX builder + self.builder.usepackages.append((packagename, options)) def add_lexer(self, alias, lexer): self.debug('[app] adding lexer: %r', (alias, lexer)) From 25a3451a4ed9f173a289440e82526c757cbcfef9 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sun, 1 Jan 2017 20:42:54 +0900 Subject: [PATCH 17/20] Reorder methods of LaTeX writer --- sphinx/writers/html.py | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/sphinx/writers/html.py b/sphinx/writers/html.py index ebffa2f28..7d6f08099 100644 --- a/sphinx/writers/html.py +++ b/sphinx/writers/html.py @@ -343,6 +343,25 @@ class HTMLTranslator(BaseTranslator): if isinstance(node.parent, nodes.table): self.body.append('') + def depart_title(self, node): + close_tag = self.context[-1] + if (self.permalink_text and self.builder.add_permalinks and + node.parent.hasattr('ids') and node.parent['ids']): + # add permalink anchor + if close_tag.startswith('%s' % ( + _('Permalink to this headline'), + self.permalink_text)) + elif isinstance(node.parent, nodes.table): + self.body.append('') + self.add_permalink_ref(node.parent, _('Permalink to this table')) + + BaseTranslator.depart_title(self, node) + # overwritten def visit_literal_block(self, node): if node.rawsource != node.astext(): @@ -709,25 +728,6 @@ class HTMLTranslator(BaseTranslator): def depart_manpage(self, node): return self.depart_literal_emphasis(node) - def depart_title(self, node): - close_tag = self.context[-1] - if (self.permalink_text and self.builder.add_permalinks and - node.parent.hasattr('ids') and node.parent['ids']): - # add permalink anchor - if close_tag.startswith('%s' % ( - _('Permalink to this headline'), - self.permalink_text)) - elif isinstance(node.parent, nodes.table): - self.body.append('') - self.add_permalink_ref(node.parent, _('Permalink to this table')) - - BaseTranslator.depart_title(self, node) - # overwritten to add even/odd classes def visit_table(self, node): From 60b7bfdfc25419d63e5061e1cd98ae58bd8c65be Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sun, 1 Jan 2017 20:47:25 +0900 Subject: [PATCH 18/20] Fix the caption of table are rendered as invalid HTML (refs: #3287) --- CHANGES | 1 + sphinx/writers/html.py | 2 ++ 2 files changed, 3 insertions(+) diff --git a/CHANGES b/CHANGES index 632280ee3..c60e8ec7e 100644 --- a/CHANGES +++ b/CHANGES @@ -19,6 +19,7 @@ Bugs fixed * #3261: ``latex_use_parts`` makes sphinx crash * The warning type ``misc.highlighting_failure`` does not work * #3294: ``add_latex_package()`` make crashes non-LaTeX builders +* The caption of table are rendered as invalid HTML (refs: #3287) Release 1.5.1 (released Dec 13, 2016) diff --git a/sphinx/writers/html.py b/sphinx/writers/html.py index 7d6f08099..016c04bd6 100644 --- a/sphinx/writers/html.py +++ b/sphinx/writers/html.py @@ -359,6 +359,8 @@ class HTMLTranslator(BaseTranslator): elif isinstance(node.parent, nodes.table): self.body.append('') self.add_permalink_ref(node.parent, _('Permalink to this table')) + elif isinstance(node.parent, nodes.table): + self.body.append('') BaseTranslator.depart_title(self, node) From 9bba475ca9a8f4b3516f53dc4b0e69e07d0cd3c8 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Mon, 2 Jan 2017 12:38:18 +0900 Subject: [PATCH 19/20] Add .mypy_cache to gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 9d163ff7b..0f9acd743 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ *.swp .dir-locals.el +.mypy_cache/ .ropeproject/ TAGS .tags From 54c8c012228559c3bf30011977984a60a9299e9b Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Tue, 3 Jan 2017 01:08:27 +0900 Subject: [PATCH 20/20] Emit warning for nested numbered toctrees (refs: #3142) --- CHANGES | 1 + doc/config.rst | 1 + sphinx/environment/managers/toctree.py | 8 ++++++-- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index c60e8ec7e..3baa9c17c 100644 --- a/CHANGES +++ b/CHANGES @@ -6,6 +6,7 @@ Features added * #3241: emit latex warning if buggy titlesec (ref #3210) * #3194: Refer the $MAKE environment variable to determine ``make`` command +* Emit warning for nested numbered toctrees (refs: #3142) Bugs fixed ---------- diff --git a/doc/config.rst b/doc/config.rst index 647aa6bc7..3a375eeeb 100644 --- a/doc/config.rst +++ b/doc/config.rst @@ -233,6 +233,7 @@ General configuration * ref.citation * ref.doc * misc.highlighting_failure + * toc.secnum * epub.unknown_project_files You can choose from these types. diff --git a/sphinx/environment/managers/toctree.py b/sphinx/environment/managers/toctree.py index e96143754..67fbfa7b6 100644 --- a/sphinx/environment/managers/toctree.py +++ b/sphinx/environment/managers/toctree.py @@ -464,10 +464,14 @@ class Toctree(EnvironmentManager): if depth == 0: return 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 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] = {} assigned.add(ref) _walk_toc(self.tocs[ref], secnums, depth,