Skip to content
This repository was archived by the owner on Nov 3, 2021. It is now read-only.

Commit 30002e7

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents 1568b35 + 6d6294f commit 30002e7

36 files changed

+1102
-960
lines changed

.travis.yml

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
1-
language: c++
21
language: python
32
python:
4-
- "2.7"
3+
- "3.7"
4+
dist: bionic
55

6-
sudo: on
7-
8-
before_install:
9-
- curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
10-
- echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
11-
- sudo apt-get update -qq
6+
addons:
7+
apt:
8+
sources:
9+
- sourceline: 'deb https://dl.yarnpkg.com/debian/ stable main'
10+
key_url: 'https://dl.yarnpkg.com/debian/pubkey.gpg'
11+
packages:
12+
- ocaml
13+
- ocamlbuild
14+
- texlive-full
15+
- yarn
1216

1317
install:
14-
- ./interpreter/meta/travis/install-ocaml.sh
15-
- sudo pip install sphinx==1.7.9
16-
- sudo apt-get install texlive-full yarn
18+
- pip install Sphinx==2.3.0
1719
- git clone https://github.com/tabatkins/bikeshed.git
1820
- pip install --editable $PWD/bikeshed
1921
- bikeshed update

document/core/Makefile

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,10 @@ STATICDIR = _static
1010
DOWNLOADDIR = _download
1111
NAME = WebAssembly
1212

13-
# Hack until we have moved to more recent Sphinx.
14-
OLDMATHJAX = https://cdn.mathjax.org/mathjax/latest/MathJax.js
15-
NEWMATHJAX = https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js
16-
1713
# Internal variables.
1814
PAPEROPT_a4 = -D latex_paper_size=a4
1915
PAPEROPT_letter = -D latex_paper_size=letter
20-
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
16+
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(SPHINXOPTS) .
2117
# the i18n builder cannot share the environment and doctrees with the others
2218
I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
2319

@@ -111,16 +107,10 @@ html:
111107
do \
112108
sed s:BASEDIR:.:g <$$file >$$file.out; \
113109
mv -f $$file.out $$file; \
114-
sed s~$(OLDMATHJAX)~$(NEWMATHJAX)~g <$$file >$$file.out; \
115-
mv -f $$file.out $$file; \
116110
done
117111
for file in `ls $(BUILDDIR)/html/*/*.html`; \
118112
do \
119113
sed s:BASEDIR:..:g <$$file >$$file.out; \
120-
sed 's;<body; <script type="text/javascript">MathJax.Hub.Config({TeX: {MAXBUFFER: 30*1024}})</script><body;' \
121-
<$$file.out >$$file; \
122-
rm -f $$file.out; \
123-
sed s~$(OLDMATHJAX)~$(NEWMATHJAX)~g <$$file >$$file.out; \
124114
mv -f $$file.out $$file; \
125115
done
126116
@echo

document/core/binary/modules.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ Their contents consist of a :ref:`name <syntax-name>` further identifying the cu
124124
\end{array}
125125
126126
.. note::
127-
If an implementation interprets the contents of a custom section, then errors in that contents, or the placement of the section, must not invalidate the module.
127+
If an implementation interprets the data of a custom section, then errors in that data, or the placement of the section, must not invalidate the module.
128128

129129

130130
.. index:: ! type section, type definition

document/core/conf.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,3 +478,9 @@
478478
rst_prolog = """
479479
.. include:: /""" + pwd + """/util/macros.def
480480
"""
481+
482+
# https://www.sphinx-doc.org/en/master/usage/extensions/math.html#confval-mathjax_config
483+
# http://docs.mathjax.org/en/v2.7-latest/options/input-processors/TeX.html
484+
mathjax_config = {
485+
'TeX': { 'MAXBUFFER': 30*1024 },
486+
}

document/core/exec/instructions.rst

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1146,13 +1146,15 @@ Memory Instructions
11461146

11471147
8. Pop the value :math:`\I32.\CONST~n` from the stack.
11481148

1149-
9. Either, try :ref:`growing <grow-mem>` :math:`\X{mem}` by :math:`n` :ref:`pages <page-size>`:
1149+
9. Let :math:`\X{err}` be the |i32| value :math:`2^{32}-1`, for which :math:`\signed_{32}(\X{err})` is :math:`-1`.
1150+
1151+
10. Either, try :ref:`growing <grow-mem>` :math:`\X{mem}` by :math:`n` :ref:`pages <page-size>`:
11501152

11511153
a. If it succeeds, push the value :math:`\I32.\CONST~\X{sz}` to the stack.
11521154

1153-
b. Else, push the value :math:`\I32.\CONST~(-1)` to the stack.
1155+
b. Else, push the value :math:`\I32.\CONST~\X{err}` to the stack.
11541156

1155-
10. Or, push the value :math:`\I32.\CONST~(-1)` to the stack.
1157+
11. Or, push the value :math:`\I32.\CONST~\X{err}` to the stack.
11561158

11571159
.. math::
11581160
~\\[-1ex]
@@ -1168,7 +1170,7 @@ Memory Instructions
11681170
\end{array}
11691171
\\[1ex]
11701172
\begin{array}{lcl@{\qquad}l}
1171-
S; F; (\I32.\CONST~n)~\MEMORYGROW &\stepto& S; F; (\I32.\CONST~{-1})
1173+
S; F; (\I32.\CONST~n)~\MEMORYGROW &\stepto& S; F; (\I32.\CONST~\signed_{32}^{-1}(-1))
11721174
\end{array}
11731175
\end{array}
11741176

document/core/exec/runtime.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,7 @@ That way, the end of the inner instruction sequence is known when part of an out
556556
When |END| is reached, i.e., the inner instruction sequence has been reduced to the empty sequence -- or rather, a sequence of :math:`n` |CONST| instructions representing the resulting values -- then the |LABEL| instruction is eliminated courtesy of its own :ref:`reduction rule <exec-label>`:
557557

558558
.. math::
559-
\LABEL_n\{\instr^n\}~\val^\ast~\END \quad\stepto\quad \val^n
559+
\LABEL_m\{\instr^\ast\}~\val^n~\END \quad\stepto\quad \val^n
560560
561561
This can be interpreted as removing the label from the stack and only leaving the locally accumulated operand values.
562562

document/core/text/modules.rst

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -440,13 +440,13 @@ The syntax for exports mirrors their :ref:`abstract syntax <syntax-export>` dire
440440
\text{(}~\text{export}~~\X{nm}{:}\Tname~~d{:}\Texportdesc_I~\text{)}
441441
&\Rightarrow& \{ \ENAME~\X{nm}, \EDESC~d \} \\
442442
\production{export description} & \Texportdesc_I &::=&
443-
\text{(}~\text{func}~~x{:}\Bfuncidx_I~\text{)}
443+
\text{(}~\text{func}~~x{:}\Tfuncidx_I~\text{)}
444444
&\Rightarrow& \EDFUNC~x \\ &&|&
445-
\text{(}~\text{table}~~x{:}\Btableidx_I~\text{)}
445+
\text{(}~\text{table}~~x{:}\Ttableidx_I~\text{)}
446446
&\Rightarrow& \EDTABLE~x \\ &&|&
447-
\text{(}~\text{memory}~~x{:}\Bmemidx_I~\text{)}
447+
\text{(}~\text{memory}~~x{:}\Tmemidx_I~\text{)}
448448
&\Rightarrow& \EDMEM~x \\ &&|&
449-
\text{(}~\text{global}~~x{:}\Bglobalidx_I~\text{)}
449+
\text{(}~\text{global}~~x{:}\Tglobalidx_I~\text{)}
450450
&\Rightarrow& \EDGLOBAL~x \\
451451
\end{array}
452452
@@ -493,8 +493,6 @@ Element Segments
493493

494494
Element segments allow for an optional :ref:`table index <text-tableidx>` to identify the table to initialize.
495495

496-
.. todo:: TODO: multi-instr elemexpr
497-
498496
.. math::
499497
\begin{array}{llclll}
500498
\production{element segment} & \Telem_I &::=&

document/core/util/bikeshed_fixup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#! /usr/bin/env python
1+
#! /usr/bin/env python3
22
# -*- coding: latin-1 -*-
33

44
import os

document/core/util/mathdef.py

Lines changed: 41 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
from sphinx.ext.mathbase import math
2-
from sphinx.ext.mathbase import displaymath
3-
from sphinx.ext.mathbase import math_role
42
from sphinx.ext.mathbase import MathDirective
5-
from sphinx.ext.mathbase import latex_visit_math
6-
from sphinx.ext.mathbase import latex_visit_displaymath
7-
from sphinx.ext.mathjax import html_visit_math
8-
from sphinx.ext.mathjax import html_visit_displaymath
9-
from sphinx.util.texescape import tex_escape_map, tex_replace_map
3+
from sphinx.util.texescape import tex_replace_map
4+
from sphinx.writers.html5 import HTML5Translator
5+
from sphinx.writers.latex import LaTeXTranslator
6+
from docutils import nodes
107
from docutils.parsers.rst.directives.misc import Replace
118
from six import text_type
129
import re
@@ -20,16 +17,8 @@ def html_hyperlink(file, id):
2017
return '\\href{../%s.html#%s}' % (file, id.replace('_', '-'))
2118

2219
def html_transform_math_xref(node):
23-
node['latex'] = \
24-
xref_re.sub(lambda m: html_hyperlink(m.group(1), m.group(2)), node['latex'])
25-
26-
def ext_html_visit_math(self, node):
27-
html_transform_math_xref(node)
28-
html_visit_math(self, node)
29-
30-
def ext_html_visit_displaymath(self, node):
31-
html_transform_math_xref(node)
32-
html_visit_displaymath(self, node)
20+
new_text = xref_re.sub(lambda m: html_hyperlink(m.group(1), m.group(2)), node.astext())
21+
node.children[0] = nodes.Text(new_text)
3322

3423
# Mirrors sphinx/writers/latex
3524
def latex_hyperlink(file, id):
@@ -39,17 +28,8 @@ def latex_hyperlink(file, id):
3928
return '\\hyperref[%s:%s]' % (file, id)
4029

4130
def latex_transform_math_xref(node):
42-
node['latex'] = \
43-
xref_re.sub(lambda m: latex_hyperlink(m.group(1), m.group(2)), node['latex'])
44-
45-
def ext_latex_visit_math(self, node):
46-
latex_transform_math_xref(node)
47-
latex_visit_math(self, node)
48-
49-
def ext_latex_visit_displaymath(self, node):
50-
latex_transform_math_xref(node)
51-
latex_visit_displaymath(self, node)
52-
31+
new_text = xref_re.sub(lambda m: latex_hyperlink(m.group(1), m.group(2)), node.astext())
32+
node.children[0] = nodes.Text(new_text)
5333

5434
# Expand mathdef names in math roles and directives
5535

@@ -75,8 +55,7 @@ def replace_mathdefs(doc, s):
7555

7656
def ext_math_role(role, raw, text, line, inliner, options = {}, content = []):
7757
text = replace_mathdefs(inliner.document, raw.split('`')[1])
78-
return math_role(role, raw, text, line, inliner, options = options,
79-
content = content)
58+
return [math(raw, text)], []
8059

8160
class ExtMathDirective(MathDirective):
8261
def run(self):
@@ -85,7 +64,7 @@ def run(self):
8564
self.content[i] = replace_mathdefs(doc, s)
8665
for i, s in enumerate(self.arguments):
8766
self.arguments[i] = replace_mathdefs(doc, s)
88-
return super(ExtMathDirective, self).run()
67+
return super().run()
8968

9069
class MathdefDirective(Replace):
9170
def run(self):
@@ -99,23 +78,45 @@ def run(self):
9978
doc = self.state.document
10079
if not hasattr(doc, 'mathdefs'):
10180
doc.mathdefs = {}
81+
# TODO: we don't ever hit the case where len(self.content) > 1
10282
for i, s in enumerate(self.content):
10383
self.content[i] = replace_mathdefs(doc, s)
10484
doc.mathdefs[name] = [arity, ''.join(self.content)]
10585
self.content[0] = ':math:`' + self.content[0]
10686
self.content[-1] = self.content[-1] + '`'
107-
return super(MathdefDirective, self).run()
108-
87+
return super().run()
88+
89+
class WebAssemblyHTML5Translator(HTML5Translator):
90+
"""
91+
Customize HTML5Translator.
92+
Convert xref in math and math block nodes to hrefs.
93+
"""
94+
def visit_math(self, node, math_env = ''):
95+
html_transform_math_xref(node)
96+
super().visit_math(node, math_env)
97+
98+
def visit_math_block(self, node, math_env = ''):
99+
html_transform_math_xref(node)
100+
super().visit_math_block(node, math_env)
101+
102+
class WebAssemblyLaTeXTranslator(LaTeXTranslator):
103+
"""
104+
Customize LaTeXTranslator.
105+
Convert xref in math and math block nodes to hyperrefs.
106+
"""
107+
def visit_math(self, node):
108+
latex_transform_math_xref(node)
109+
super().visit_math(node)
110+
111+
def visit_math_block(self, node):
112+
latex_transform_math_xref(node)
113+
super().visit_math_block(node)
109114

110115
# Setup
111116

112117
def setup(app):
113-
app.add_node(math,
114-
html = (ext_html_visit_math, None),
115-
latex = (ext_latex_visit_math, None))
116-
app.add_node(displaymath,
117-
html = (ext_html_visit_displaymath, None),
118-
latex = (ext_latex_visit_displaymath, None))
118+
app.set_translator('html', WebAssemblyHTML5Translator)
119+
app.set_translator('latex', WebAssemblyLaTeXTranslator)
119120
app.add_role('math', ext_math_role)
120-
app.add_directive('math', ExtMathDirective)
121+
app.add_directive('math', ExtMathDirective, override = True)
121122
app.add_directive('mathdef', MathdefDirective)

document/core/util/mathdefbs.py

Lines changed: 19 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,12 @@
44
# mathdef.py controlled by buildername.
55

66
from sphinx.ext.mathbase import math
7-
from sphinx.ext.mathbase import displaymath
8-
from sphinx.ext.mathbase import math_role
97
from sphinx.ext.mathbase import MathDirective
10-
from sphinx.ext.mathbase import latex_visit_math
11-
from sphinx.ext.mathbase import latex_visit_displaymath
128
from sphinx.ext.mathjax import html_visit_math
139
from sphinx.ext.mathjax import html_visit_displaymath
14-
from sphinx.util.texescape import tex_escape_map, tex_replace_map
10+
from sphinx.writers.html5 import HTML5Translator
11+
from docutils import nodes
1512
from docutils.parsers.rst.directives.misc import Replace
16-
from six import text_type
1713
import re
1814

1915

@@ -25,36 +21,8 @@ def html_hyperlink(file, id):
2521
return '\\href{#%s}' % (id.replace('_', '-'))
2622

2723
def html_transform_math_xref(node):
28-
node['latex'] = \
29-
xref_re.sub(lambda m: html_hyperlink(m.group(1), m.group(2)), node['latex'])
30-
31-
def ext_html_visit_math(self, node):
32-
html_transform_math_xref(node)
33-
html_visit_math(self, node)
34-
35-
def ext_html_visit_displaymath(self, node):
36-
html_transform_math_xref(node)
37-
html_visit_displaymath(self, node)
38-
39-
# Mirrors sphinx/writers/latex
40-
def latex_hyperlink(file, id):
41-
id = text_type(id).translate(tex_replace_map).\
42-
encode('ascii', 'backslashreplace').decode('ascii').\
43-
replace('_', '-').replace('\\', '_')
44-
return '\\hyperref[%s:%s]' % (file, id)
45-
46-
def latex_transform_math_xref(node):
47-
node['latex'] = \
48-
xref_re.sub(lambda m: latex_hyperlink(m.group(1), m.group(2)), node['latex'])
49-
50-
def ext_latex_visit_math(self, node):
51-
latex_transform_math_xref(node)
52-
latex_visit_math(self, node)
53-
54-
def ext_latex_visit_displaymath(self, node):
55-
latex_transform_math_xref(node)
56-
latex_visit_displaymath(self, node)
57-
24+
new_text = xref_re.sub(lambda m: html_hyperlink(m.group(1), m.group(2)), node.astext())
25+
node.children[0] = nodes.Text(new_text)
5826

5927
# Expand mathdef names in math roles and directives
6028

@@ -80,8 +48,7 @@ def replace_mathdefs(doc, s):
8048

8149
def ext_math_role(role, raw, text, line, inliner, options = {}, content = []):
8250
text = replace_mathdefs(inliner.document, raw.split('`')[1])
83-
return math_role(role, raw, text, line, inliner, options = options,
84-
content = content)
51+
return [math(raw, text)], []
8552

8653
class ExtMathDirective(MathDirective):
8754
def run(self):
@@ -111,16 +78,23 @@ def run(self):
11178
self.content[-1] = self.content[-1] + '`'
11279
return super(MathdefDirective, self).run()
11380

81+
class WebAssemblyHTML5Translator(HTML5Translator):
82+
"""
83+
Customize HTML5Translator.
84+
Convert xref in math and math block nodes to hrefs.
85+
"""
86+
def visit_math(self, node, math_env = ''):
87+
html_transform_math_xref(node)
88+
super().visit_math(node, math_env)
89+
90+
def visit_math_block(self, node, math_env = ''):
91+
html_transform_math_xref(node)
92+
super().visit_math_block(node, math_env)
11493

11594
# Setup
11695

11796
def setup(app):
118-
app.add_node(math,
119-
html = (ext_html_visit_math, None),
120-
latex = (ext_latex_visit_math, None))
121-
app.add_node(displaymath,
122-
html = (ext_html_visit_displaymath, None),
123-
latex = (ext_latex_visit_displaymath, None))
97+
app.set_translator('singlehtml', WebAssemblyHTML5Translator)
12498
app.add_role('math', ext_math_role)
125-
app.add_directive('math', ExtMathDirective)
99+
app.add_directive('math', ExtMathDirective, override = True)
126100
app.add_directive('mathdef', MathdefDirective)

0 commit comments

Comments
 (0)