|
| 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 | + |
1 | 66 | import hashlib |
2 | 67 | from pathlib import Path |
3 | 68 |
|
@@ -35,6 +100,9 @@ def math_role(role, rawtext, text, lineno, inliner, |
35 | 100 |
|
36 | 101 |
|
37 | 102 | class MathDirective(Directive): |
| 103 | + """ |
| 104 | + The ``.. mathmpl::`` directive, as documented in the module's docstring. |
| 105 | + """ |
38 | 106 | has_content = True |
39 | 107 | required_arguments = 0 |
40 | 108 | optional_arguments = 0 |
|
0 commit comments