diff --git a/CHANGES b/CHANGES index bceb672d0..8b698ebf0 100644 --- a/CHANGES +++ b/CHANGES @@ -38,7 +38,7 @@ Bugs fixed * #4067: Return non-zero exit status when make subprocess fails * #4055: graphviz: the :align: option does not work for SVG output * #4055: graphviz: the :align: center option does not work for latex output - +* #4051: ``warn()`` function for HTML theme outputs 'None' string Testing diff --git a/sphinx/builders/html.py b/sphinx/builders/html.py index 0265f6a1b..90e4574cc 100644 --- a/sphinx/builders/html.py +++ b/sphinx/builders/html.py @@ -898,7 +898,6 @@ class StandaloneHTMLBuilder(Builder): outfilename=None, event_arg=None): # type: (unicode, Dict, unicode, unicode, Any) -> None ctx = self.globalcontext.copy() - ctx['warn'] = self.warn # current_page_name is backwards compatibility ctx['pagename'] = ctx['current_page_name'] = pagename ctx['encoding'] = self.config.html_output_encoding @@ -931,6 +930,13 @@ class StandaloneHTMLBuilder(Builder): return False ctx['hasdoc'] = hasdoc + def warn(*args, **kwargs): + # type: (Any, Any) -> unicode + """Simple warn() wrapper for themes.""" + self.warn(*args, **kwargs) + return '' # return empty string + ctx['warn'] = warn + ctx['toctree'] = lambda **kw: self._get_local_toctree(pagename, **kw) self.add_sidebars(pagename, ctx) ctx.update(addctx)