| 1 |
|
| 2 |
Latex Math |
| 3 |
========== |
| 4 |
|
| 5 |
Breathe has basic support for latex math markup in the doxygen comments. A |
| 6 |
class with a comment like: |
| 7 |
|
| 8 |
.. code-block:: cpp |
| 9 |
|
| 10 |
/** |
| 11 |
* @brief A class |
| 12 |
* |
| 13 |
* A inline formula: \f$ f(x) = a + b \f$ |
| 14 |
* |
| 15 |
* A display style formula: |
| 16 |
* @f[ |
| 17 |
* \int_a^b f(x) dx = F(b) - F(a) |
| 18 |
* @f] |
| 19 |
*/ |
| 20 |
class MathHelper |
| 21 |
{ |
| 22 |
public: |
| 23 |
MathHelper() {} |
| 24 |
~MathHelper() {} |
| 25 |
} |
| 26 |
|
| 27 |
|
| 28 |
Will be renderer as: |
| 29 |
|
| 30 |
.. cpp:namespace:: @ex_latexmath |
| 31 |
|
| 32 |
.. doxygenclass:: MathHelper |
| 33 |
:project: latexmath |
| 34 |
:members: |
| 35 |
:undoc-members: |
| 36 |
|
| 37 |
|
| 38 |
Without any additional configuration except for including a math extension in |
| 39 |
the Sphinx ``conf.py``: |
| 40 |
|
| 41 |
.. code-block:: python |
| 42 |
|
| 43 |
extensions = ["breathe", "sphinx.ext.mathjax"] |
| 44 |
|
| 45 |
The specific environment formula fails when using ``sphinx.ext.pngmath`` so more |
| 46 |
work is needed. |
| 47 |
|
| 48 |
Implementation |
| 49 |
-------------- |
| 50 |
|
| 51 |
Breathe uses a internal reStructuredText node provided by |
| 52 |
``sphinx.ext.mathbase`` which is then picked up and rendered by the extension |
| 53 |
chosen in the ``conf.py``. It does not pass any additional options through to |
| 54 |
the node, so settings like ``label`` and ``nowrap`` are currently not supported. |
| 55 |
|
| 56 |
Credits |
| 57 |
------- |
| 58 |
|
| 59 |
Thank you to `dazzlezhang <https://github.com/dazzlezhang>`_ for providing |
| 60 |
examples and a full run down of necessary details. It made the implementation |
| 61 |
much easier. |