Fix #6887: Sphinx crashes with docutils-0.16b0

This commit is contained in:
Takeshi KOMIYA 2019-12-14 11:40:50 +09:00
parent 1a54a7229c
commit faedcc48cc
7 changed files with 17 additions and 17 deletions

View File

@ -25,7 +25,8 @@ matrix:
- TOXENV=du15 - TOXENV=du15
- PYTEST_ADDOPTS="--cov ./ --cov-append --cov-config setup.cfg" - PYTEST_ADDOPTS="--cov ./ --cov-append --cov-config setup.cfg"
- python: 'nightly' - python: 'nightly'
env: TOXENV=py38 env:
- TOXENV=du16
- python: '3.6' - python: '3.6'
env: TOXENV=docs env: TOXENV=docs
- python: '3.6' - python: '3.6'

View File

@ -84,6 +84,7 @@ Bugs fixed
* #6886: LaTeX: xelatex converts straight double quotes into right curly ones * #6886: LaTeX: xelatex converts straight double quotes into right curly ones
(shows when :confval:`smartquotes` is ``False``) (shows when :confval:`smartquotes` is ``False``)
* #6876: LaTeX: multi-line display of authors on title page has ragged edges * #6876: LaTeX: multi-line display of authors on title page has ragged edges
* #6887: Sphinx crashes with docutils-0.16b0
Testing Testing
-------- --------

View File

@ -234,14 +234,13 @@ class LaTeXBuilder(Builder):
destination = SphinxFileOutput(destination_path=path.join(self.outdir, targetname), destination = SphinxFileOutput(destination_path=path.join(self.outdir, targetname),
encoding='utf-8', overwrite_if_changed=True) encoding='utf-8', overwrite_if_changed=True)
with progress_message(__("processing %s") % targetname): with progress_message(__("processing %s") % targetname):
toctrees = self.env.get_doctree(docname).traverse(addnodes.toctree) doctree = self.env.get_doctree(docname)
if toctrees: toctree = next(iter(doctree.traverse(addnodes.toctree)), None)
if toctrees[0].get('maxdepth') > 0: if toctree and toctree.get('maxdepth') > 0:
tocdepth = toctrees[0].get('maxdepth') tocdepth = toctree.get('maxdepth')
else:
tocdepth = None
else: else:
tocdepth = None tocdepth = None
doctree = self.assemble_doctree( doctree = self.assemble_doctree(
docname, toctree_only, docname, toctree_only,
appendices=((docclass != 'howto') and self.config.latex_appendices or [])) appendices=((docclass != 'howto') and self.config.latex_appendices or []))

View File

@ -612,15 +612,13 @@ class StandardDomain(Domain):
sectname = self.get_numfig_title(node) sectname = self.get_numfig_title(node)
if not sectname: if not sectname:
continue continue
elif node.traverse(addnodes.toctree):
n = node.traverse(addnodes.toctree)[0]
if n.get('caption'):
sectname = n['caption']
else:
continue
else: else:
# anonymous-only labels toctree = next(iter(node.traverse(addnodes.toctree)), None)
continue if toctree and toctree.get('caption'):
sectname = toctree.get('caption')
else:
# anonymous-only labels
continue
self.labels[name] = docname, labelid, sectname self.labels[name] = docname, labelid, sectname
def add_object(self, objtype: str, name: str, docname: str, labelid: str) -> None: def add_object(self, objtype: str, name: str, docname: str, labelid: str) -> None:

View File

@ -148,7 +148,7 @@ def apply_source_workaround(node: Element) -> None:
logger.debug('[i18n] PATCH: %r to have rawsource: %s', logger.debug('[i18n] PATCH: %r to have rawsource: %s',
get_full_module_name(node), repr_domxml(node)) get_full_module_name(node), repr_domxml(node))
# strip classifier from rawsource of term # strip classifier from rawsource of term
for classifier in reversed(node.parent.traverse(nodes.classifier)): for classifier in reversed(list(node.parent.traverse(nodes.classifier))):
node.rawsource = re.sub(r'\s*:\s*%s' % re.escape(classifier.astext()), node.rawsource = re.sub(r'\s*:\s*%s' % re.escape(classifier.astext()),
'', node.rawsource) '', node.rawsource)

View File

@ -573,7 +573,7 @@ def test_literalinclude_pydecorators(app, status, warning):
def test_code_block_highlighted(app, status, warning): def test_code_block_highlighted(app, status, warning):
app.builder.build(['highlight']) app.builder.build(['highlight'])
doctree = app.env.get_doctree('highlight') doctree = app.env.get_doctree('highlight')
codeblocks = doctree.traverse(nodes.literal_block) codeblocks = list(doctree.traverse(nodes.literal_block))
assert codeblocks[0]['language'] == 'default' assert codeblocks[0]['language'] == 'default'
assert codeblocks[1]['language'] == 'python2' assert codeblocks[1]['language'] == 'python2'

View File

@ -14,6 +14,7 @@ deps =
du13: docutils==0.13.1 du13: docutils==0.13.1
du14: docutils==0.14 du14: docutils==0.14
du15: docutils==0.15 du15: docutils==0.15
du16: docutils==0.16b0.dev0
extras = extras =
test test
setenv = setenv =