Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit40a7742

Browse files
committed
Unbreak the Sphinx 1.8 build by renaming :math: to :mathmpl:.
1 parent848d9fc commit40a7742

File tree

4 files changed

+44
-27
lines changed

4 files changed

+44
-27
lines changed

‎doc-requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# Install the documentation requirements with:
77
# pip install -r doc-requirements.txt
88
#
9-
sphinx>=1.3,!=1.5.0,!=1.6.4,!=1.7.3,<1.8
9+
sphinx>=1.3,!=1.5.0,!=1.6.4,!=1.7.3
1010
colorspacious
1111
ipython
1212
ipywidgets
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
:orphan:
2+
3+
``:math:`` directive renamed to ``:mathmpl:``
4+
`````````````````````````````````````````````
5+
6+
The ``:math:`` rst role provided by `matplotlib.sphinxext.mathmpl` has been
7+
renamed to ``:mathmpl:`` to avoid conflicting with the ``:math:`` role that
8+
Sphinx 1.8 provides by default. (``:mathmpl:`` uses Matplotlib to render math
9+
expressions to images embedded in html, whereas Sphinx uses MathJax.)
10+
11+
When using Sphinx<1.8, both names (``:math:`` and ``:mathmpl:``) remain
12+
available for backcompatibility.

‎lib/matplotlib/sphinxext/mathmpl.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
importhashlib
12
importos
23
importsys
3-
fromhashlibimportmd5
4+
importwarnings
45

56
fromdocutilsimportnodes
67
fromdocutils.parsers.rstimportdirectives
7-
importwarnings
8+
importsphinx
89

910
frommatplotlibimportrcParams
1011
frommatplotlib.mathtextimportMathTextParser
@@ -70,7 +71,7 @@ def latex2png(latex, filename, fontset='cm'):
7071
deflatex2html(node,source):
7172
inline=isinstance(node.parent,nodes.TextElement)
7273
latex=node['latex']
73-
name='math-%s'%md5(latex.encode()).hexdigest()[-10:]
74+
name='math-%s'%hashlib.md5(latex.encode()).hexdigest()[-10:]
7475

7576
destdir=os.path.join(setup.app.builder.outdir,'_images','mathmpl')
7677
ifnotos.path.exists(destdir):
@@ -119,9 +120,13 @@ def depart_latex_math_latex(self, node):
119120
app.add_node(latex_math,
120121
html=(visit_latex_math_html,depart_latex_math_html),
121122
latex=(visit_latex_math_latex,depart_latex_math_latex))
122-
app.add_role('math',math_role)
123-
app.add_directive('math',math_directive,
123+
app.add_role('mathmpl',math_role)
124+
app.add_directive('mathmpl',math_directive,
124125
True, (0,0,0),**options_spec)
126+
ifsphinx.version_info< (1,8):
127+
app.add_role('math',math_role)
128+
app.add_directive('math',math_directive,
129+
True, (0,0,0),**options_spec)
125130

126131
metadata= {'parallel_read_safe':True,'parallel_write_safe':True}
127132
returnmetadata

‎tutorials/text/mathtext.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
# # math text
4545
# plt.title(r'$\alpha > \beta$')
4646
#
47-
# produces ":math:`\alpha > \beta`".
47+
# produces ":mathmpl:`\alpha > \beta`".
4848
#
4949
# .. note::
5050
# Mathtext should be placed between a pair of dollar signs ($). To
@@ -77,9 +77,9 @@
7777
#
7878
# \alpha_i > \beta_i
7979
#
80-
# Some symbols automatically put their sub/superscripts under and over
81-
#theoperator. For example, to write the sum of :math:`x_i` from :math:`0` to
82-
#:math:`\infty`, you could do::
80+
# Some symbols automatically put their sub/superscripts under and over the
81+
# operator. For example, to write the sum of :mathmpl:`x_i` from :mathmpl:`0`
82+
#to :mathmpl:`\infty`, you could do::
8383
#
8484
# r'$\sum_{i=0}^\infty x_i$'
8585
#
@@ -200,13 +200,13 @@
200200
# ============================ ==================================
201201
# Command Result
202202
# ============================ ==================================
203-
# ``\mathrm{Roman}`` :math:`\mathrm{Roman}`
204-
# ``\mathit{Italic}`` :math:`\mathit{Italic}`
205-
# ``\mathtt{Typewriter}`` :math:`\mathtt{Typewriter}`
206-
# ``\mathcal{CALLIGRAPHY}`` :math:`\mathcal{CALLIGRAPHY}`
203+
# ``\mathrm{Roman}`` :mathmpl:`\mathrm{Roman}`
204+
# ``\mathit{Italic}`` :mathmpl:`\mathit{Italic}`
205+
# ``\mathtt{Typewriter}`` :mathmpl:`\mathtt{Typewriter}`
206+
# ``\mathcal{CALLIGRAPHY}`` :mathmpl:`\mathcal{CALLIGRAPHY}`
207207
# ============================ ==================================
208208
#
209-
# .. role:: math-stix(math)
209+
# .. role:: math-stix(mathmpl)
210210
# :fontset: stix
211211
#
212212
# When using the `STIX <http://www.stixfonts.org/>`_ fonts, you also have the choice of:
@@ -294,16 +294,16 @@
294294
# ============================== =================================
295295
# Command Result
296296
# ============================== =================================
297-
# ``\acute a`` or ``\'a`` :math:`\acute a`
298-
# ``\bar a`` :math:`\bar a`
299-
# ``\breve a`` :math:`\breve a`
300-
# ``\ddot a`` or ``\''a`` :math:`\ddot a`
301-
# ``\dot a`` or ``\.a`` :math:`\dot a`
302-
# ``\grave a`` or ``\`a`` :math:`\grave a`
303-
# ``\hat a`` or ``\^a`` :math:`\hat a`
304-
# ``\tilde a`` or ``\~a`` :math:`\tilde a`
305-
# ``\vec a`` :math:`\vec a`
306-
# ``\overline{abc}`` :math:`\overline{abc}`
297+
# ``\acute a`` or ``\'a`` :mathmpl:`\acute a`
298+
# ``\bar a`` :mathmpl:`\bar a`
299+
# ``\breve a`` :mathmpl:`\breve a`
300+
# ``\ddot a`` or ``\''a`` :mathmpl:`\ddot a`
301+
# ``\dot a`` or ``\.a`` :mathmpl:`\dot a`
302+
# ``\grave a`` or ``\`a`` :mathmpl:`\grave a`
303+
# ``\hat a`` or ``\^a`` :mathmpl:`\hat a`
304+
# ``\tilde a`` or ``\~a`` :mathmpl:`\tilde a`
305+
# ``\vec a`` :mathmpl:`\vec a`
306+
# ``\overline{abc}`` :mathmpl:`\overline{abc}`
307307
# ============================== =================================
308308
#
309309
# In addition, there are two special accents that automatically adjust
@@ -312,8 +312,8 @@
312312
# ============================== =================================
313313
# Command Result
314314
# ============================== =================================
315-
# ``\widehat{xyz}`` :math:`\widehat{xyz}`
316-
# ``\widetilde{xyz}`` :math:`\widetilde{xyz}`
315+
# ``\widehat{xyz}`` :mathmpl:`\widehat{xyz}`
316+
# ``\widetilde{xyz}`` :mathmpl:`\widetilde{xyz}`
317317
# ============================== =================================
318318
#
319319
# Care should be taken when putting accents on lower-case i's and j's.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp