Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ffe49ba

Browse files
committed
equation rendering is now working using Jens Mortensen's
mathpng extension. The syntax is illustrated in the developers guide, in the "Documenting Matplotlib" section svn path=/trunk/matplotlib/; revision=5228
1 parent 2c895b3 commit ffe49ba

4 files changed

Lines changed: 24 additions & 6 deletions

File tree

doc/api_reference/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
# Add any Sphinx extension module names here, as strings. They can be extensions
2525
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
26-
extensions = ['mathml', 'sphinx.ext.autodoc']
26+
extensions = ['mathpng', 'sphinx.ext.autodoc']
2727

2828
# Add any paths that contain templates here, relative to this directory.
2929
templates_path = ['_templates']

doc/sphinxext/mathpng.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,11 @@ def latex2html(node, source):
9595
os.system('latex --interaction=nonstopmode math.tex > /dev/null')
9696
os.system('dvipng -bgTransparent -Ttight --noghostscript -l10 ' +
9797
'-o _static/%s.png math.dvi > /dev/null' % name)
98-
path = source.split('/doc/')[-1].count('/') * '../' + '_static'
98+
path = '_static'
99+
count = source.split('/doc/')[-1].count('/')
100+
for i in range(count):
101+
if os.path.exists(path): break
102+
path = '../'+path
99103
if inline and '_' in latex:
100104
align = 'align="absmiddle" '
101105
else:

doc/users_guide/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
# Add any Sphinx extension module names here, as strings. They can be extensions
2929
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
30-
extensions = ['mathml', 'sphinx.ext.autodoc']
30+
extensions = ['mathpng', 'sphinx.ext.autodoc']
3131

3232
# Add any paths that contain templates here, relative to this directory.
3333
templates_path = ['_templates']

doc/users_guide/documenting_mpl.txt

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ Documenting Matplotlib
44

55
The documentation for matplotlib is generated from ReStructured Text
66
using the Sphinx_ documentation generation tool. Sphinx-0.4 or later
7-
is required to generate xml files to render mathematical expressions
8-
with mathml. Currently this means we need to install from the svn
7+
is required. Currently this means we need to install from the svn
98
repository by doing::
109

1110
svn co http://svn.python.org/projects/doctools/trunk sphinx
@@ -34,10 +33,25 @@ coding_guide.txt is just a placeholder, it contains one line only to
3433
gets its contents from the CODING_GUIDE file in the trunk:
3534
``.. include:: ../../CODING_GUIDE``.
3635

36+
Mathematical expressions can be rendered as png images in html, and in
37+
the usual way by latex. For example:
38+
39+
``math:`sin(x_n^2)`` yields: :math:`sin(x_n^2)`, and::
40+
41+
.. math::
42+
43+
\int_{-\infty}^{\infty}\frac{e^{i\phi}}{1+x^2\frac{e^{i\phi}}{1+x^2}}``
44+
45+
yields:
46+
47+
.. math::
48+
49+
\int_{-\infty}^{\infty}\frac{e^{i\phi}}{1+x^2\frac{e^{i\phi}}{1+x^2}}
50+
3751
The output produced by Sphinx can be configured by editing the conf.py
3852
files located in the documentation source directories.
3953

4054
The Sphinx website contains plenty of documentation_ concerning ReST
4155
markup and working with Sphinx in general.
4256

43-
.. _documentation: http://sphinx.pocoo.org/contents.html
57+
.. _documentation: http://sphinx.pocoo.org/contents.html

0 commit comments

Comments
 (0)