diff --git a/add-to-conf.py b/add-to-conf.py index 16f28b4..2000279 100644 --- a/add-to-conf.py +++ b/add-to-conf.py @@ -11,36 +11,12 @@ ###################################################### Pygments Style -# https://stackoverflow.com/questions/48615629/how-to-include-pygments-styles-in-a-sphinx-project # # There is an existing pygments_style bit - search for it and replace it with this. # -from pygments.style import Style -from pygments.token import Keyword, Name, Comment, String, Error, \ - Number, Operator, Generic, Whitespace - -class OODSStyle(Style): - background_color = "#fbfbfb" - default_style = "" - styles = { - String: "#d9534f" - } - - -def pygments_monkeypatch_style(mod_name, cls): - import sys - import pygments.styles - cls_name = cls.__name__ - mod = type(__import__("os"))(mod_name) - setattr(mod, cls_name, cls) - setattr(pygments.styles, mod_name, mod) - sys.modules["pygments.styles." + mod_name] = mod - from pygments.styles import STYLE_MAP - STYLE_MAP[mod_name] = mod_name + "::" + cls_name - - -pygments_monkeypatch_style("oods", OODSStyle) +import oods.pygments +oods.pygments.pygments_monkeypatch_style("oods", oods.pygments.OODSStyle) pygments_style = "oods" diff --git a/python/__init__.py b/python/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/python/oods/__init__.py b/python/oods/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/python/oods/pygments.py b/python/oods/pygments.py new file mode 100644 index 0000000..8c91cc9 --- /dev/null +++ b/python/oods/pygments.py @@ -0,0 +1,25 @@ +from pygments.style import Style +from pygments.token import Keyword, Name, Comment, String, Error, \ + Number, Operator, Generic, Whitespace + +# https://stackoverflow.com/questions/48615629/how-to-include-pygments-styles-in-a-sphinx-project + + +class OODSStyle(Style): + background_color = "#fbfbfb" + default_style = "" + styles = { + String: "#d9534f" + } + + +def pygments_monkeypatch_style(mod_name, cls): + import sys + import pygments.styles + cls_name = cls.__name__ + mod = type(__import__("os"))(mod_name) + setattr(mod, cls_name, cls) + setattr(pygments.styles, mod_name, mod) + sys.modules["pygments.styles." + mod_name] = mod + from pygments.styles import STYLE_MAP + STYLE_MAP[mod_name] = mod_name + "::" + cls_name diff --git a/vagrant/build-all.sh b/vagrant/build-all.sh index 2659799..bbc6afc 100755 --- a/vagrant/build-all.sh +++ b/vagrant/build-all.sh @@ -8,5 +8,7 @@ cd /vagrant/bootstrap_build && grunt sass cp /vagrant/bootstrap_build/bootstrap/dist/js/bootstrap.* /vagrant/themes/oods/static/bootstrap-4.0.0/js/ +export PYTHONPATH=$PYTHONPATH:/vagrant/python + sphinx-build -a /vagrant/data-standard/docs /out/ diff --git a/vagrant/build-sphinx.sh b/vagrant/build-sphinx.sh index c2560fc..b17fc68 100755 --- a/vagrant/build-sphinx.sh +++ b/vagrant/build-sphinx.sh @@ -2,5 +2,7 @@ set -e +export PYTHONPATH=$PYTHONPATH:/vagrant/python + sphinx-build -a /vagrant/data-standard/docs /out/