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 line numbers was not shown on warnings in LaTeX and texinfo builders
* Fix filenames were not shown on warnings of citations * 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 in LaTeX and texinfo builders
* Fix line numbers was not shown on warnings of indecies
Release 1.3.4 (released Jan 12, 2016) 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 import addnodes
from sphinx.util import url_re, get_matching_docs, docname_join, split_into, \ 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.nodes import clean_astext, make_refnode, WarningStream, is_translatable
from sphinx.util.osutil import SEP, getcwd, fs_encoding from sphinx.util.osutil import SEP, getcwd, fs_encoding
from sphinx.util.i18n import find_catalog_files from sphinx.util.i18n import find_catalog_files
@ -1123,7 +1123,14 @@ class BuildEnvironment:
def note_indexentries_from(self, docname, document): def note_indexentries_from(self, docname, document):
entries = self.indexentries[docname] = [] entries = self.indexentries[docname] = []
for node in document.traverse(addnodes.index): for node in document.traverse(addnodes.index):
entries.extend(node['entries']) 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): def note_citations_from(self, docname, document):
for node in document.traverse(nodes.citation): for node in document.traverse(nodes.citation):

View File

@ -421,23 +421,21 @@ def split_into(n, type, value):
def split_index_msg(type, value): def split_index_msg(type, value):
# new entry types must be listed in directives/other.py! # new entry types must be listed in directives/other.py!
result = [] if type == 'single':
try: try:
if type == 'single': result = split_into(2, 'single', value)
try: except ValueError:
result = split_into(2, 'single', value) result = split_into(1, 'single', value)
except ValueError: elif type == 'pair':
result = split_into(1, 'single', value) result = split_into(2, 'pair', value)
elif type == 'pair': elif type == 'triple':
result = split_into(2, 'pair', value) result = split_into(3, 'triple', value)
elif type == 'triple': elif type == 'see':
result = split_into(3, 'triple', value) result = split_into(2, 'see', value)
elif type == 'see': elif type == 'seealso':
result = split_into(2, 'see', value) result = split_into(2, 'see', value)
elif type == 'seealso': else:
result = split_into(2, 'see', value) raise ValueError('invalid %s index entry %r' % (type, value))
except ValueError:
pass
return result 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 \ reading included file u'.*?wrongenc.inc' seems to be wrong, try giving an \
:encoding: option\\n? :encoding: option\\n?
%(root)s/includes.txt:4: WARNING: download file not readable: .*?nonexisting.png %(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 \ (%(root)s/undecodable.txt:3: WARNING: undecodable source characters, replacing \
with "\\?": b?'here: >>>(\\\\|/)xbb<<<' 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/images.txt:20: WARNING: no matching candidate for image URI u'foo.\\*'
%(root)s/footnote.txt:60: WARNING: citation not found: missing %(root)s/footnote.txt:60: WARNING: citation not found: missing
%(root)s/markup.txt:158: WARNING: unknown option: &option %(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: if PY3:
@ -376,7 +374,7 @@ def check_extra_entries(outdir):
assert (outdir / 'robots.txt').isfile() 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'}, confoverrides={'html_context.hckey_co': 'hcval_co'},
tags=['testtag']) tags=['testtag'])
def test_html_output(app, status, warning): 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/markup.txt:158: WARNING: unknown option: &option
%(root)s/footnote.txt:60: WARNING: citation not found: missing %(root)s/footnote.txt:60: WARNING: citation not found: missing
%(root)s/images.txt:20: WARNING: no matching candidate for image URI u'foo.\\*' %(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: if PY3:
LATEX_WARNINGS = remove_unicode_literals(LATEX_WARNINGS) 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): def test_latex(app, status, warning):
LaTeXTranslator.ignore_missing_images = True LaTeXTranslator.ignore_missing_images = True
app.builder.build_all() app.builder.build_all()
@ -94,7 +92,7 @@ def test_latex(app, status, warning):
os.chdir(cwd) os.chdir(cwd)
@with_app(buildername='latex', @with_app(buildername='latex', freshenv=True, # use freshenv to check warnings
confoverrides={'latex_documents': [ confoverrides={'latex_documents': [
('contents', 'SphinxTests.tex', 'Sphinx Tests Documentation', ('contents', 'SphinxTests.tex', 'Sphinx Tests Documentation',
'Georg Brandl \\and someone else', 'howto'), 'Georg Brandl \\and someone else', 'howto'),

View File

@ -33,7 +33,7 @@ if PY3:
TEXINFO_WARNINGS = remove_unicode_literals(TEXINFO_WARNINGS) 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): def test_texinfo(app, status, warning):
TexinfoTranslator.ignore_missing_images = True TexinfoTranslator.ignore_missing_images = True
app.builder.build_all() app.builder.build_all()