diff options
Diffstat (limited to 'sphinx/ext/jsmath.py')
-rw-r--r-- | sphinx/ext/jsmath.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/sphinx/ext/jsmath.py b/sphinx/ext/jsmath.py index 05d5dc290..e523b54c8 100644 --- a/sphinx/ext/jsmath.py +++ b/sphinx/ext/jsmath.py @@ -10,6 +10,8 @@ :license: BSD, see LICENSE for details. """ +from typing import TYPE_CHECKING + from docutils import nodes import sphinx @@ -19,13 +21,20 @@ from sphinx.ext.mathbase import setup_math as mathbase_setup from sphinx.locale import _ +if TYPE_CHECKING: + from typing import Any, Dict # NOQA + from sphinx.application import Sphinx # NOQA + + def html_visit_math(self, node): + # type: (nodes.NodeVisitor, nodes.Node) -> None self.body.append(self.starttag(node, 'span', '', CLASS='math notranslate')) self.body.append(self.encode(node['latex']) + '</span>') raise nodes.SkipNode def html_visit_displaymath(self, node): + # type: (nodes.NodeVisitor, nodes.Node) -> None if node['nowrap']: self.body.append(self.starttag(node, 'div', CLASS='math notranslate')) self.body.append(self.encode(node['latex'])) @@ -53,6 +62,7 @@ def html_visit_displaymath(self, node): def builder_inited(app): + # type: (Sphinx) -> None if not app.config.jsmath_path: raise ExtensionError('jsmath_path config value must be set for the ' 'jsmath extension to work') @@ -60,6 +70,7 @@ def builder_inited(app): def setup(app): + # type: (Sphinx) -> Dict[unicode, Any] try: mathbase_setup(app, (html_visit_math, None), (html_visit_displaymath, None)) except ExtensionError: |