mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Closes #901: Emit a warning when using docutils' new "math" markup without a Sphinx math extension active.
This commit is contained in:
3
CHANGES
3
CHANGES
@@ -43,6 +43,9 @@ Bugs fixed
|
||||
pngmath-generated images. This rebuilds them correctly when
|
||||
``pngmath_latex_preamble`` changes.
|
||||
|
||||
* #901: Emit a warning when using docutils' new "math" markup without a Sphinx
|
||||
math extension active.
|
||||
|
||||
Documentation
|
||||
-------------
|
||||
|
||||
|
||||
@@ -54,6 +54,7 @@ class TextBuilder(Builder):
|
||||
self.writer = TextWriter(self)
|
||||
|
||||
def write_doc(self, docname, doctree):
|
||||
self.current_docname = docname
|
||||
destination = StringOutput(encoding='utf-8')
|
||||
self.writer.write(doctree, destination)
|
||||
outfilename = path.join(self.outdir, os_path(docname) + self.out_suffix)
|
||||
|
||||
@@ -551,6 +551,13 @@ class HTMLTranslator(BaseTranslator):
|
||||
node['classes'].append('field-odd')
|
||||
self.body.append(self.starttag(node, 'tr', '', CLASS='field'))
|
||||
|
||||
def visit_math(self, node, math_env=''):
|
||||
self.builder.warn('using "math" markup without a Sphinx math extension '
|
||||
'active, please use one of the math extensions '
|
||||
'described at http://sphinx-doc.org/ext/math.html',
|
||||
(self.builder.current_docname, node.line))
|
||||
raise nodes.SkipNode
|
||||
|
||||
def unknown_visit(self, node):
|
||||
raise NotImplementedError('Unknown node: ' + node.__class__.__name__)
|
||||
|
||||
|
||||
@@ -1532,5 +1532,14 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
||||
def depart_system_message(self, node):
|
||||
self.body.append('\n')
|
||||
|
||||
def visit_math(self, node):
|
||||
self.builder.warn('using "math" markup without a Sphinx math extension '
|
||||
'active, please use one of the math extensions '
|
||||
'described at http://sphinx-doc.org/ext/math.html',
|
||||
(self.curfilestack[-1], node.line))
|
||||
raise nodes.SkipNode
|
||||
|
||||
visit_math_block = visit_math
|
||||
|
||||
def unknown_visit(self, node):
|
||||
raise NotImplementedError('Unknown node: ' + node.__class__.__name__)
|
||||
|
||||
@@ -342,5 +342,13 @@ class ManualPageTranslator(BaseTranslator):
|
||||
def depart_inline(self, node):
|
||||
pass
|
||||
|
||||
def visit_math(self, node):
|
||||
self.builder.warn('using "math" markup without a Sphinx math extension '
|
||||
'active, please use one of the math extensions '
|
||||
'described at http://sphinx-doc.org/ext/math.html')
|
||||
raise nodes.SkipNode
|
||||
|
||||
visit_math_block = visit_math
|
||||
|
||||
def unknown_visit(self, node):
|
||||
raise NotImplementedError('Unknown node: ' + node.__class__.__name__)
|
||||
|
||||
@@ -1393,3 +1393,11 @@ class TexinfoTranslator(nodes.NodeVisitor):
|
||||
pass
|
||||
def depart_pending_xref(self, node):
|
||||
pass
|
||||
|
||||
def visit_math(self, node):
|
||||
self.builder.warn('using "math" markup without a Sphinx math extension '
|
||||
'active, please use one of the math extensions '
|
||||
'described at http://sphinx-doc.org/ext/math.html')
|
||||
raise nodes.SkipNode
|
||||
|
||||
visit_math_block = visit_math
|
||||
|
||||
@@ -152,6 +152,7 @@ class TextTranslator(nodes.NodeVisitor):
|
||||
|
||||
def __init__(self, document, builder):
|
||||
nodes.NodeVisitor.__init__(self, document)
|
||||
self.builder = builder
|
||||
|
||||
newlines = builder.config.text_newlines
|
||||
if newlines == 'windows':
|
||||
@@ -838,5 +839,14 @@ class TextTranslator(nodes.NodeVisitor):
|
||||
self.body.append(node.astext())
|
||||
raise nodes.SkipNode
|
||||
|
||||
def visit_math(self, node):
|
||||
self.builder.warn('using "math" markup without a Sphinx math extension '
|
||||
'active, please use one of the math extensions '
|
||||
'described at http://sphinx-doc.org/ext/math.html',
|
||||
(self.builder.current_docname, node.line))
|
||||
raise nodes.SkipNode
|
||||
|
||||
visit_math_block = visit_math
|
||||
|
||||
def unknown_visit(self, node):
|
||||
raise NotImplementedError('Unknown node: ' + node.__class__.__name__)
|
||||
|
||||
Reference in New Issue
Block a user