Skip to content

Commit

Permalink
Start python folder to hold code used in theme. Moved pygments stuff …
Browse files Browse the repository at this point in the history
…to it.

Now pygments changes needed to conf.py are minimal, and any updates to pygments will appear in peoples builds with no conf.py edits needed.

May help with #5
  • Loading branch information
odscjames committed Apr 27, 2018
1 parent 771ee71 commit 5cbb774
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 26 deletions.
28 changes: 2 additions & 26 deletions add-to-conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"


Expand Down
Empty file added python/__init__.py
Empty file.
Empty file added python/oods/__init__.py
Empty file.
25 changes: 25 additions & 0 deletions python/oods/pygments.py
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions vagrant/build-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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/

2 changes: 2 additions & 0 deletions vagrant/build-sphinx.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@

set -e

export PYTHONPATH=$PYTHONPATH:/vagrant/python

sphinx-build -a /vagrant/data-standard/docs /out/

0 comments on commit 5cbb774

Please sign in to comment.