mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix typehints: sphinx.util.math
This commit is contained in:
parent
545bb77b1e
commit
9a636683a0
@ -22,6 +22,7 @@ if False:
|
|||||||
from typing import Any, Dict # NOQA
|
from typing import Any, Dict # NOQA
|
||||||
from sphinx.application import Sphinx # NOQA
|
from sphinx.application import Sphinx # NOQA
|
||||||
from sphinx.environment import BuildEnvironment # NOQA
|
from sphinx.environment import BuildEnvironment # NOQA
|
||||||
|
from sphinx.writers.html import HTMLTranslator # NOQA
|
||||||
|
|
||||||
|
|
||||||
def html_visit_math(self, node):
|
def html_visit_math(self, node):
|
||||||
@ -32,7 +33,7 @@ def html_visit_math(self, node):
|
|||||||
|
|
||||||
|
|
||||||
def html_visit_displaymath(self, node):
|
def html_visit_displaymath(self, node):
|
||||||
# type: (nodes.NodeVisitor, nodes.Node) -> None
|
# type: (HTMLTranslator, nodes.Node) -> None
|
||||||
if node['nowrap']:
|
if node['nowrap']:
|
||||||
self.body.append(self.starttag(node, 'div', CLASS='math notranslate nohighlight'))
|
self.body.append(self.starttag(node, 'div', CLASS='math notranslate nohighlight'))
|
||||||
self.body.append(self.encode(node.astext()))
|
self.body.append(self.encode(node.astext()))
|
||||||
|
@ -25,6 +25,7 @@ if False:
|
|||||||
from typing import Any, Dict # NOQA
|
from typing import Any, Dict # NOQA
|
||||||
from sphinx.application import Sphinx # NOQA
|
from sphinx.application import Sphinx # NOQA
|
||||||
from sphinx.environment import BuildEnvironment # NOQA
|
from sphinx.environment import BuildEnvironment # NOQA
|
||||||
|
from sphinx.writers.html import HTMLTranslator # NOQA
|
||||||
|
|
||||||
|
|
||||||
def html_visit_math(self, node):
|
def html_visit_math(self, node):
|
||||||
@ -37,7 +38,7 @@ def html_visit_math(self, node):
|
|||||||
|
|
||||||
|
|
||||||
def html_visit_displaymath(self, node):
|
def html_visit_displaymath(self, node):
|
||||||
# type: (nodes.NodeVisitor, nodes.Node) -> None
|
# type: (HTMLTranslator, nodes.Node) -> None
|
||||||
self.body.append(self.starttag(node, 'div', CLASS='math notranslate nohighlight'))
|
self.body.append(self.starttag(node, 'div', CLASS='math notranslate nohighlight'))
|
||||||
if node['nowrap']:
|
if node['nowrap']:
|
||||||
self.body.append(self.encode(node.astext()))
|
self.body.append(self.encode(node.astext()))
|
||||||
|
@ -13,11 +13,11 @@
|
|||||||
if False:
|
if False:
|
||||||
# For type annotation
|
# For type annotation
|
||||||
from docutils import nodes # NOQA
|
from docutils import nodes # NOQA
|
||||||
from docutils.writers.html4css1 import Writer # NOQA
|
from sphinx.builders.html import HTMLTranslator # NOQA
|
||||||
|
|
||||||
|
|
||||||
def get_node_equation_number(writer, node):
|
def get_node_equation_number(writer, node):
|
||||||
# type: (Writer, nodes.Node) -> unicode
|
# type: (HTMLTranslator, nodes.Node) -> unicode
|
||||||
if writer.builder.config.math_numfig and writer.builder.config.numfig:
|
if writer.builder.config.math_numfig and writer.builder.config.numfig:
|
||||||
figtype = 'displaymath'
|
figtype = 'displaymath'
|
||||||
if writer.builder.name == 'singlehtml':
|
if writer.builder.name == 'singlehtml':
|
||||||
@ -27,11 +27,9 @@ def get_node_equation_number(writer, node):
|
|||||||
|
|
||||||
id = node['ids'][0]
|
id = node['ids'][0]
|
||||||
number = writer.builder.fignumbers.get(key, {}).get(id, ())
|
number = writer.builder.fignumbers.get(key, {}).get(id, ())
|
||||||
number = '.'.join(map(str, number))
|
return '.'.join(map(str, number))
|
||||||
else:
|
else:
|
||||||
number = node['number']
|
return node['number']
|
||||||
|
|
||||||
return number
|
|
||||||
|
|
||||||
|
|
||||||
def wrap_displaymath(text, label, numbering):
|
def wrap_displaymath(text, label, numbering):
|
||||||
|
Loading…
Reference in New Issue
Block a user