Fix line numbers was not shown on warnings of indecies

This commit is contained in:
Takeshi KOMIYA 2016-01-13 11:37:07 +09:00
parent 7898c64cf4
commit 3f998a0096
6 changed files with 30 additions and 28 deletions

View File

@ -7,6 +7,7 @@ Bugs fixed
* Fix line numbers was not shown on warnings in LaTeX and texinfo builders
* Fix filenames were not shown on warnings of citations
* Fix line numbers was not shown on warnings in LaTeX and texinfo builders
* Fix line numbers was not shown on warnings of indecies
Release 1.3.4 (released Jan 12, 2016)
=====================================

View File

@ -38,7 +38,7 @@ from docutils.frontend import OptionParser
from sphinx import addnodes
from sphinx.util import url_re, get_matching_docs, docname_join, split_into, \
FilenameUniqDict, get_figtype, import_object
FilenameUniqDict, get_figtype, import_object, split_index_msg
from sphinx.util.nodes import clean_astext, make_refnode, WarningStream, is_translatable
from sphinx.util.osutil import SEP, getcwd, fs_encoding
from sphinx.util.i18n import find_catalog_files
@ -1123,6 +1123,13 @@ class BuildEnvironment:
def note_indexentries_from(self, docname, document):
entries = self.indexentries[docname] = []
for node in document.traverse(addnodes.index):
try:
for type, value, tid, main in node['entries']:
split_index_msg(type, value)
except ValueError as exc:
self.warn_node(exc, node)
node.parent.remove(node)
else:
entries.extend(node['entries'])
def note_citations_from(self, docname, document):

View File

@ -421,8 +421,6 @@ def split_into(n, type, value):
def split_index_msg(type, value):
# new entry types must be listed in directives/other.py!
result = []
try:
if type == 'single':
try:
result = split_into(2, 'single', value)
@ -436,8 +434,8 @@ def split_index_msg(type, value):
result = split_into(2, 'see', value)
elif type == 'seealso':
result = split_into(2, 'see', value)
except ValueError:
pass
else:
raise ValueError('invalid %s index entry %r' % (type, value))
return result

View File

@ -31,6 +31,7 @@ http://www.python.org/logo.png
reading included file u'.*?wrongenc.inc' seems to be wrong, try giving an \
:encoding: option\\n?
%(root)s/includes.txt:4: WARNING: download file not readable: .*?nonexisting.png
(%(root)s/markup.txt:351: WARNING: invalid single index entry u'')?
(%(root)s/undecodable.txt:3: WARNING: undecodable source characters, replacing \
with "\\?": b?'here: >>>(\\\\|/)xbb<<<'
)?"""
@ -39,9 +40,6 @@ HTML_WARNINGS = ENV_WARNINGS + """\
%(root)s/images.txt:20: WARNING: no matching candidate for image URI u'foo.\\*'
%(root)s/footnote.txt:60: WARNING: citation not found: missing
%(root)s/markup.txt:158: WARNING: unknown option: &option
%(root)s/markup.txt:: WARNING: invalid single index entry u''
%(root)s/markup.txt:: WARNING: invalid pair index entry u''
%(root)s/markup.txt:: WARNING: invalid pair index entry u'keyword; '
"""
if PY3:
@ -376,7 +374,7 @@ def check_extra_entries(outdir):
assert (outdir / 'robots.txt').isfile()
@gen_with_app(buildername='html',
@gen_with_app(buildername='html', freshenv=True, # use freshenv to check warnings
confoverrides={'html_context.hckey_co': 'hcval_co'},
tags=['testtag'])
def test_html_output(app, status, warning):

View File

@ -27,15 +27,13 @@ LATEX_WARNINGS = ENV_WARNINGS + """\
%(root)s/markup.txt:158: WARNING: unknown option: &option
%(root)s/footnote.txt:60: WARNING: citation not found: missing
%(root)s/images.txt:20: WARNING: no matching candidate for image URI u'foo.\\*'
WARNING: invalid pair index entry u''
WARNING: invalid pair index entry u'keyword; '
"""
if PY3:
LATEX_WARNINGS = remove_unicode_literals(LATEX_WARNINGS)
@with_app(buildername='latex')
@with_app(buildername='latex', freshenv=True) # use freshenv to check warnings
def test_latex(app, status, warning):
LaTeXTranslator.ignore_missing_images = True
app.builder.build_all()
@ -94,7 +92,7 @@ def test_latex(app, status, warning):
os.chdir(cwd)
@with_app(buildername='latex',
@with_app(buildername='latex', freshenv=True, # use freshenv to check warnings
confoverrides={'latex_documents': [
('contents', 'SphinxTests.tex', 'Sphinx Tests Documentation',
'Georg Brandl \\and someone else', 'howto'),

View File

@ -33,7 +33,7 @@ if PY3:
TEXINFO_WARNINGS = remove_unicode_literals(TEXINFO_WARNINGS)
@with_app('texinfo')
@with_app('texinfo', freshenv=True) # use freshenv to check warnings
def test_texinfo(app, status, warning):
TexinfoTranslator.ignore_missing_images = True
app.builder.build_all()