| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -6,7 +6,7 @@ | |||
| 6 | 6 | # Install the documentation requirements with: | |
| 7 | 7 | # pip install -r doc-requirements.txt | |
| 8 | 8 | # | |
| 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 | ||
| 10 | 10 | colorspacious | |
| 11 | 11 | ipython | |
| 12 | 12 | ipywidgets | |
| Original file line number | Diff line number | Diff 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. | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,10 +1,11 @@ | |||
| 1 | + import hashlib | ||
| 1 | 2 | import os | |
| 2 | 3 | import sys | |
| 3 | - from hashlib import md5 | ||
| 4 | + import warnings | ||
| 4 | 5 | ||
| 5 | 6 | from docutils import nodes | |
| 6 | 7 | from docutils.parsers.rst import directives | |
| 7 | - import warnings | ||
| 8 | + import sphinx | ||
| 8 | 9 | ||
| 9 | 10 | from matplotlib import rcParams | |
| 10 | 11 | from matplotlib.mathtext import MathTextParser | |
@@ -70,7 +71,7 @@ def latex2png(latex, filename, fontset='cm'): | |||
| 70 | 71 | def latex2html(node, source): | |
| 71 | 72 | inline = isinstance(node.parent, nodes.TextElement) | |
| 72 | 73 | latex = node['latex'] | |
| 73 | - name = 'math-%s' % md5(latex.encode()).hexdigest()[-10:] | ||
| 74 | + name = 'math-%s' % hashlib.md5(latex.encode()).hexdigest()[-10:] | ||
| 74 | 75 | ||
| 75 | 76 | destdir = os.path.join(setup.app.builder.outdir, '_images', 'mathmpl') | |
| 76 | 77 | if not os.path.exists(destdir): | |
@@ -119,9 +120,13 @@ def depart_latex_math_latex(self, node): | |||
| 119 | 120 | app.add_node(latex_math, | |
| 120 | 121 | html=(visit_latex_math_html, depart_latex_math_html), | |
| 121 | 122 | 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, | ||
| 124 | 125 | True, (0, 0, 0), **options_spec) | |
| 126 | + if sphinx.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) | ||
| 125 | 130 | ||
| 126 | 131 | metadata = {'parallel_read_safe': True, 'parallel_write_safe': True} | |
| 127 | 132 | return metadata | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -44,7 +44,7 @@ | |||
| 44 | 44 | # # math text | |
| 45 | 45 | # plt.title(r'$\alpha > \beta$') | |
| 46 | 46 | # | |
| 47 | - # produces ":math:`\alpha > \beta`". | ||
| 47 | + # produces ":mathmpl:`\alpha > \beta`". | ||
| 48 | 48 | # | |
| 49 | 49 | # .. note:: | |
| 50 | 50 | # Mathtext should be placed between a pair of dollar signs ($). To | |
@@ -77,9 +77,9 @@ | |||
| 77 | 77 | # | |
| 78 | 78 | # \alpha_i > \beta_i | |
| 79 | 79 | # | |
| 80 | - # Some symbols automatically put their sub/superscripts under and over | ||
| 81 | - # the operator. 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:: | ||
| 83 | 83 | # | |
| 84 | 84 | # r'$\sum_{i=0}^\infty x_i$' | |
| 85 | 85 | # | |
@@ -200,13 +200,13 @@ | |||
| 200 | 200 | # ============================ ================================== | |
| 201 | 201 | # Command Result | |
| 202 | 202 | # ============================ ================================== | |
| 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}` | ||
| 207 | 207 | # ============================ ================================== | |
| 208 | 208 | # | |
| 209 | - # .. role:: math-stix(math) | ||
| 209 | + # .. role:: math-stix(mathmpl) | ||
| 210 | 210 | # :fontset: stix | |
| 211 | 211 | # | |
| 212 | 212 | # When using the `STIX <http://www.stixfonts.org/>`_ fonts, you also have the choice of: | |
@@ -294,16 +294,16 @@ | |||
| 294 | 294 | # ============================== ================================= | |
| 295 | 295 | # Command Result | |
| 296 | 296 | # ============================== ================================= | |
| 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}` | ||
| 307 | 307 | # ============================== ================================= | |
| 308 | 308 | # | |
| 309 | 309 | # In addition, there are two special accents that automatically adjust | |
@@ -312,8 +312,8 @@ | |||
| 312 | 312 | # ============================== ================================= | |
| 313 | 313 | # Command Result | |
| 314 | 314 | # ============================== ================================= | |
| 315 | - # ``\widehat{xyz}`` :math:`\widehat{xyz}` | ||
| 316 | - # ``\widetilde{xyz}`` :math:`\widetilde{xyz}` | ||
| 315 | + # ``\widehat{xyz}`` :mathmpl:`\widehat{xyz}` | ||
| 316 | + # ``\widetilde{xyz}`` :mathmpl:`\widetilde{xyz}` | ||
| 317 | 317 | # ============================== ================================= | |
| 318 | 318 | # | |
| 319 | 319 | # Care should be taken when putting accents on lower-case i's and j's. | |
| Back | FazBrowse Home | New Git URL |
0 commit comments