Skip to content

Commit

Permalink
DOC: switch to KaTeX for math rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
hagenw committed Feb 10, 2019
1 parent 059410f commit 38e2c5c
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 31 deletions.
13 changes: 11 additions & 2 deletions doc/conf.py
Expand Up @@ -17,6 +17,11 @@
import os
from subprocess import check_output

import sphinxcontrib.katex as katex

sys.path.insert(0, os.path.abspath('.'))
from math_definitions import latex_macros

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
Expand All @@ -32,7 +37,7 @@
# ones.
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.mathjax',
'sphinxcontrib.katex',
'sphinx.ext.viewcode',
'sphinx.ext.napoleon', # support for NumPy-style docstrings
'sphinx.ext.intersphinx',
Expand Down Expand Up @@ -149,6 +154,10 @@
# If true, keep warnings as "system message" paragraphs in the built documents.
#keep_warnings = False

# Math settings
katex_macros = katex.latex_defs_to_katex_macros(latex_macros)
katex_options = 'macros: {' + katex_macros + '}'


# -- Options for HTML output ----------------------------------------------

Expand Down Expand Up @@ -251,7 +260,7 @@ def setup(app):
#'pointsize': '10pt',

# Additional stuff for the LaTeX preamble.
#'preamble': '',
'preamble': latex_macros,

'printindex': '',
}
Expand Down
10 changes: 0 additions & 10 deletions doc/math-definitions.rst

This file was deleted.

10 changes: 10 additions & 0 deletions doc/math_definitions.py
@@ -0,0 +1,10 @@
latex_macros = r"""
\def \dirac #1{\operatorname{\delta}\left(#1\right)}
\def \e #1{\operatorname{e}^{#1}}
\def \Hankel #3{\mathop{{}H_{#2}^{(#1)}}\!\left(#3\right)}
\def \hankel #3{\mathop{{}h_{#2}^{(#1)}}\!\left(#3\right)}
\def \i {\mathrm{i}}
\def \scalarprod #2{\left\langle#1,#2\right\rangle}
\def \vec #1{\mathbf{#1}}
\def \wc {\frac{\omega}{c}}
"""
1 change: 1 addition & 0 deletions doc/requirements.txt
Expand Up @@ -3,6 +3,7 @@ Sphinx-RTD-Theme
nbsphinx
ipykernel
sphinxcontrib-bibtex
sphinxcontrib-katex

NumPy
SciPy
Expand Down
7 changes: 1 addition & 6 deletions sfs/mono/drivingfunction.py
@@ -1,9 +1,4 @@
"""Compute driving functions for various systems.
.. include:: math-definitions.rst
"""

"""Compute driving functions for various systems."""
import numpy as np
from numpy.core.umath_tests import inner1d # element-wise inner product
from scipy.special import jn, hankel2
Expand Down
6 changes: 1 addition & 5 deletions sfs/time/drivingfunction.py
@@ -1,8 +1,4 @@
"""Compute time based driving functions for various systems.
.. include:: math-definitions.rst
"""
"""Compute time based driving functions for various systems."""
import numpy as np
from numpy.core.umath_tests import inner1d # element-wise inner product
from .. import defs
Expand Down
2 changes: 0 additions & 2 deletions sfs/time/source.py
Expand Up @@ -2,8 +2,6 @@
The Green's function describes the spatial sound propagation over time.
.. include:: math-definitions.rst
"""

import numpy as np
Expand Down
7 changes: 1 addition & 6 deletions sfs/util.py
@@ -1,9 +1,4 @@
"""Various utility functions.
.. include:: math-definitions.rst
"""

"""Various utility functions."""
import collections
import numpy as np
from scipy.special import spherical_jn, spherical_yn
Expand Down

0 comments on commit 38e2c5c

Please sign in to comment.