Skip to content

Commit 7ac178e

Browse files
committed
Document mathmpl Sphinx extension.
1 parent 654967b commit 7ac178e

File tree

3 files changed

+76
-0
lines changed

3 files changed

+76
-0
lines changed

doc/api/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ Alphabetical list of modules:
8282
rcsetup_api.rst
8383
sankey_api.rst
8484
scale_api.rst
85+
sphinxext_mathmpl_api.rst
8586
sphinxext_plot_directive_api.rst
8687
spines_api.rst
8788
style_api.rst

doc/api/sphinxext_mathmpl_api.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
================================
2+
``matplotlib.sphinxext.mathmpl``
3+
================================
4+
5+
.. automodule:: matplotlib.sphinxext.mathmpl
6+
:exclude-members: latex_math
7+
:no-undoc-members:

lib/matplotlib/sphinxext/mathmpl.py

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,68 @@
1+
r"""
2+
A role and directive to display mathtext in Sphinx
3+
==================================================
4+
5+
.. warning::
6+
In most cases, you will likely want to use one of `Sphinx's builtin Math
7+
extensions
8+
<https://www.sphinx-doc.org/en/master/usage/extensions/math.html>`__
9+
instead of this one.
10+
11+
Mathtext may be included in two ways:
12+
13+
1. Inline, using the role::
14+
15+
This text uses inline math: :mathmpl:`\alpha > \beta`.
16+
17+
which produces:
18+
19+
This text uses inline math: :mathmpl:`\alpha > \beta`.
20+
21+
2. Standalone, using the directive::
22+
23+
Here is some standalone math:
24+
25+
.. mathmpl::
26+
27+
\alpha > \beta
28+
29+
which produces:
30+
31+
Here is some standalone math:
32+
33+
.. mathmpl::
34+
35+
\alpha > \beta
36+
37+
Options
38+
-------
39+
40+
The ``mathmpl`` role and directive both support the following options:
41+
42+
fontset : str, default: 'cm'
43+
The font set to use when displaying math. See :rc:`mathtext.fontset`.
44+
45+
fontsize : float
46+
The font size, in points. Defaults to the value from the extension
47+
configuration option defined below.
48+
49+
Configuration options
50+
---------------------
51+
52+
The mathtext extension has the following configuration options:
53+
54+
mathmpl_fontsize : float, default: 10.0
55+
Default font size, in points.
56+
57+
mathmpl_srcset : list of str, default: []
58+
Additional image sizes to generate when embedding in HTML, to support
59+
`responsive resolution images
60+
<https://developer.mozilla.org/en-US/docs/Learn/HTML/Multimedia_and_embedding/Responsive_images>`__.
61+
The list should contain additional x-descriptors (``'1.5x'``, ``'2x'``,
62+
etc.) to generate (1x is the default and always included.)
63+
64+
"""
65+
166
import hashlib
267
from pathlib import Path
368

@@ -35,6 +100,9 @@ def math_role(role, rawtext, text, lineno, inliner,
35100

36101

37102
class MathDirective(Directive):
103+
"""
104+
The ``.. mathmpl::`` directive, as documented in the module's docstring.
105+
"""
38106
has_content = True
39107
required_arguments = 0
40108
optional_arguments = 0

0 commit comments

Comments
 (0)