diff options
author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2018-11-28 02:25:04 +0900 |
---|---|---|
committer | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2018-11-28 15:23:26 +0900 |
commit | 337a5c484a0d5249f8e0ec5017db3152e83c00e7 (patch) | |
tree | c88e9ecdf128d511efdf895e6e89e025c93bc12b /sphinx/ext/jsmath.py | |
parent | 83e4107a309e9fc99cf9c9c65b748897b9d5a0e5 (diff) | |
download | sphinx-git-337a5c484a0d5249f8e0ec5017db3152e83c00e7.tar.gz |
Fix annotaions for extensions
Diffstat (limited to 'sphinx/ext/jsmath.py')
-rw-r--r-- | sphinx/ext/jsmath.py | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/sphinx/ext/jsmath.py b/sphinx/ext/jsmath.py index 0df5d4413..ed4f7739e 100644 --- a/sphinx/ext/jsmath.py +++ b/sphinx/ext/jsmath.py @@ -10,9 +10,13 @@ :license: BSD, see LICENSE for details. """ +from typing import cast + from docutils import nodes import sphinx +from sphinx.builders.html import StandaloneHTMLBuilder +from sphinx.domains.math import MathDomain from sphinx.errors import ExtensionError from sphinx.locale import _ from sphinx.util.math import get_node_equation_number @@ -27,14 +31,14 @@ if False: def html_visit_math(self, node): - # type: (nodes.NodeVisitor, nodes.Node) -> None + # type: (HTMLTranslator, nodes.math) -> None self.body.append(self.starttag(node, 'span', '', CLASS='math notranslate nohighlight')) self.body.append(self.encode(node.astext()) + '</span>') raise nodes.SkipNode def html_visit_displaymath(self, node): - # type: (HTMLTranslator, nodes.Node) -> None + # type: (HTMLTranslator, nodes.math_block) -> None if node['nowrap']: self.body.append(self.starttag(node, 'div', CLASS='math notranslate nohighlight')) self.body.append(self.encode(node.astext())) @@ -69,9 +73,11 @@ def install_jsmath(app, env): raise ExtensionError('jsmath_path config value must be set for the ' 'jsmath extension to work') - if env.get_domain('math').has_equations(): # type: ignore + builder = cast(StandaloneHTMLBuilder, app.builder) + domain = cast(MathDomain, env.get_domain('math')) + if domain.has_equations(): # Enable jsmath only if equations exists - app.builder.add_js_file(app.config.jsmath_path) # type: ignore + builder.add_js_file(app.config.jsmath_path) def setup(app): |