diff --git a/CHANGES b/CHANGES index 3888b2305..56fc6b11d 100644 --- a/CHANGES +++ b/CHANGES @@ -13,6 +13,7 @@ Features added self-signed HTTPS servers in linkcheck and intersphinx * #2215: make.bat generated by sphinx-quickstart can be called from another dir. Thanks to Timotheus Kampik. +* #3185: Add new warning type ``misc.highlighting_failure`` Bugs fixed ---------- diff --git a/doc/config.rst b/doc/config.rst index a3f45abe9..9c74d664f 100644 --- a/doc/config.rst +++ b/doc/config.rst @@ -232,6 +232,7 @@ General configuration * ref.option * ref.citation * ref.doc + * misc.highlighting_failure You can choose from these types. @@ -239,6 +240,10 @@ General configuration .. versionadded:: 1.4 + .. versionchanged:: 1.5 + + Added ``misc.highlighting_failure`` + .. confval:: needs_sphinx If set to a ``major.minor`` version string like ``'1.1'``, Sphinx will diff --git a/sphinx/highlighting.py b/sphinx/highlighting.py index 9594b5336..4b4ba87da 100644 --- a/sphinx/highlighting.py +++ b/sphinx/highlighting.py @@ -143,7 +143,8 @@ class PygmentsBridge(object): pass # automatic highlighting failed. elif warn: warn('Could not lex literal_block as "%s". ' - 'Highlighting skipped.' % lang) + 'Highlighting skipped.' % lang, + type='misc', subtype='higlighting_failure') else: raise exc hlsource = highlight(source, lexers['none'], formatter) diff --git a/sphinx/writers/html.py b/sphinx/writers/html.py index ba2b758d8..5c0fa0fee 100644 --- a/sphinx/writers/html.py +++ b/sphinx/writers/html.py @@ -363,8 +363,8 @@ class HTMLTranslator(BaseTranslator): else: opts = {} - def warner(msg): - self.builder.warn(msg, (self.builder.current_docname, node.line)) + def warner(msg, **kwargs): + self.builder.warn(msg, (self.builder.current_docname, node.line), **kwargs) highlighted = self.highlighter.highlight_block( node.rawsource, lang, opts=opts, warn=warner, linenos=linenos, **highlight_args) diff --git a/sphinx/writers/latex.py b/sphinx/writers/latex.py index ed62308c4..104401152 100644 --- a/sphinx/writers/latex.py +++ b/sphinx/writers/latex.py @@ -1954,8 +1954,8 @@ class LaTeXTranslator(nodes.NodeVisitor): else: opts = {} - def warner(msg): - self.builder.warn(msg, (self.curfilestack[-1], node.line)) + def warner(msg, **kwargs): + self.builder.warn(msg, (self.curfilestack[-1], node.line), **kwargs) hlcode = self.highlighter.highlight_block(code, lang, opts=opts, warn=warner, linenos=linenos, **highlight_args)