I have a Matrix say 3 x 3, I want to display it in the Generated sphinx documentation of Python docs.
def Matrix_func():
"""
[1 4 7 ]
M = [2 5 8 ]
[3 6 9 ]
"""
Currently the above matrix is not printed as it is in the generated sphinx docs.
The Sphinx docstring formatA pair of :param: and :type: directive options must be used for each parameter we wish to document. The :raises: option is used to describe any errors that are raised by the code, while the :return: and :rtype: options are used to describe any values returned by our code.
Or to use MathJax extension
In your sphinx config.py
add the mathjax
extension
extensions = [
# ... other extensions
'sphinx.ext.mathjax',
]
Then a pretty array will render with:
def Matrix_func():
r"""
.. math::
M = \begin{bmatrix}
1 & 4 & 7 \\
2 & 5 & 8 \\
3 & 6 & 9
\end{bmatrix}
"""
this answer is 2.25 years late, but I hope it helps somebody ;)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With