Fix #3185: Add new warning type `misc.highlighting_failure`

This commit is contained in:
Takeshi KOMIYA 2016-12-03 15:25:15 +09:00
parent b799249c77
commit 12660e44b5
5 changed files with 12 additions and 5 deletions

View File

@ -13,6 +13,7 @@ Features added
self-signed HTTPS servers in linkcheck and intersphinx self-signed HTTPS servers in linkcheck and intersphinx
* #2215: make.bat generated by sphinx-quickstart can be called from another dir. * #2215: make.bat generated by sphinx-quickstart can be called from another dir.
Thanks to Timotheus Kampik. Thanks to Timotheus Kampik.
* #3185: Add new warning type ``misc.highlighting_failure``
Bugs fixed Bugs fixed
---------- ----------

View File

@ -232,6 +232,7 @@ General configuration
* ref.option * ref.option
* ref.citation * ref.citation
* ref.doc * ref.doc
* misc.highlighting_failure
You can choose from these types. You can choose from these types.
@ -239,6 +240,10 @@ General configuration
.. versionadded:: 1.4 .. versionadded:: 1.4
.. versionchanged:: 1.5
Added ``misc.highlighting_failure``
.. confval:: needs_sphinx .. confval:: needs_sphinx
If set to a ``major.minor`` version string like ``'1.1'``, Sphinx will If set to a ``major.minor`` version string like ``'1.1'``, Sphinx will

View File

@ -143,7 +143,8 @@ class PygmentsBridge(object):
pass # automatic highlighting failed. pass # automatic highlighting failed.
elif warn: elif warn:
warn('Could not lex literal_block as "%s". ' warn('Could not lex literal_block as "%s". '
'Highlighting skipped.' % lang) 'Highlighting skipped.' % lang,
type='misc', subtype='higlighting_failure')
else: else:
raise exc raise exc
hlsource = highlight(source, lexers['none'], formatter) hlsource = highlight(source, lexers['none'], formatter)

View File

@ -363,8 +363,8 @@ class HTMLTranslator(BaseTranslator):
else: else:
opts = {} opts = {}
def warner(msg): def warner(msg, **kwargs):
self.builder.warn(msg, (self.builder.current_docname, node.line)) self.builder.warn(msg, (self.builder.current_docname, node.line), **kwargs)
highlighted = self.highlighter.highlight_block( highlighted = self.highlighter.highlight_block(
node.rawsource, lang, opts=opts, warn=warner, linenos=linenos, node.rawsource, lang, opts=opts, warn=warner, linenos=linenos,
**highlight_args) **highlight_args)

View File

@ -1954,8 +1954,8 @@ class LaTeXTranslator(nodes.NodeVisitor):
else: else:
opts = {} opts = {}
def warner(msg): def warner(msg, **kwargs):
self.builder.warn(msg, (self.curfilestack[-1], node.line)) self.builder.warn(msg, (self.curfilestack[-1], node.line), **kwargs)
hlcode = self.highlighter.highlight_block(code, lang, opts=opts, hlcode = self.highlighter.highlight_block(code, lang, opts=opts,
warn=warner, linenos=linenos, warn=warner, linenos=linenos,
**highlight_args) **highlight_args)