conf.py 5.82 KB
Newer Older
Batson Iii, John's avatar
Batson Iii, John committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

# -- Path setup --------------------------------------------------------------

# 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.
#
# import os
# import sys
# sys.path.insert(0, os.path.abspath('.'))


# -- Project information -----------------------------------------------------

Batson Iii's avatar
Batson Iii committed
20

Batson Iii, John's avatar
Batson Iii, John committed
21
project = 'SCALE Manual'
Batson Iii, John's avatar
Batson Iii, John committed
22
copyright = '2020, SCALE developers'
23
author = 'SCALE developers'
Batson Iii, John's avatar
Batson Iii, John committed
24

Batson Iii, John's avatar
Batson Iii, John committed
25
26
27
pygments_style = "default"
highlight_language = "python"

Batson Iii, John's avatar
Batson Iii, John committed
28
29
30
31
32
33
34
35
36
37
38
39
# The full version, including alpha/beta/rc tags
release = '0.0.1'


# -- General configuration ---------------------------------------------------

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
import sys, os
sys.path.append(os.path.abspath('extensions'))

Batson Iii's avatar
Batson Iii committed
40

Batson Iii, John's avatar
Batson Iii, John committed
41

Batson Iii's avatar
Batson Iii committed
42
43
extensions = ['sphinxcontrib.bibtex', "sphinx_rtd_theme", 'sphinxcontrib.rsvgconverter']

Batson Iii, John's avatar
Batson Iii, John committed
44

45
46
47
48
49
50
from SCALE_highlighting import ScaleLexer, ScaleStyle, set_pygments_style
from sphinx.highlighting import lexers
lexers['scale'] = ScaleLexer()
set_pygments_style("scale", ScaleStyle)
pygments_style = "scale"

Batson Iii, John's avatar
Batson Iii, John committed
51
52
53
54
55
56
57
58
numfig = True

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
Batson Iii's avatar
Batson Iii committed
59
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
Batson Iii, John's avatar
Batson Iii, John committed
60
61
62
63
64
65
66


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

# The theme to use for HTML and HTML Help pages.  See the documentation for
# a list of builtin themes.
#
Batson Iii's avatar
Batson Iii committed
67
68
69
70

html_theme = 'alabaster'


Batson Iii, John's avatar
Batson Iii, John committed
71
72
73
74
75

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
Batson Iii, John's avatar
Batson Iii, John committed
76
77
78
79

html_css_files = [
    'custom.css',
]
Batson Iii's avatar
Batson Iii committed
80

Batson Iii's avatar
Batson Iii committed
81
82
83
def setup(app):
   app.add_stylesheet('css/custom.css')

Batson Iii's avatar
Batson Iii committed
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
from pygments.lexer import RegexLexer, bygroups, include, inherit, words
from pygments.style import Style
from pygments import token
################################################################################
def set_pygments_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
################################################################################
class ScaleStyle(Style):
    default_style = ""
    styles = {
        token.Comment: 'italic #008000',
        token.Number: 'bold #ff0000',
        token.Name: 'bold #0000FF',
        token.Name.Function: 'bold #000000',
        token.Text: 'bold #000000',
        token.String: 'italic #ff0000',
    }
################################################################################
class ScaleLexer(RegexLexer):
    name = 'Scale'
    aliases = ['scale']
    filenames = ['*.inp']

    tokens = {
        'root': [
            (r'^=.*\n', token.Name.Function),
            (r'^\'.*\n', token.Comment),
            (r'^\‘.*\n', token.Comment),
            (r'[ ]{1,}', token.Text),
            (r'\b(?i)(end([ ]{1,}|\n)end)\s\w+', token.Name,'block'),
            (r'\b(?i)(read|end)\s\w+', token.Name,'block'),
            (r'\b(?i)(end\s*$)', token.Name,'block'),
            (r'\b(?i)(location|cylgeometry|gridgeometry)\s', token.Name, 'block'),
            (r'\b(?i)(energybounds|timebounds)\s', token.Name, 'block'),
            (r'\b(?i)(response|distribution)\s', token.Name, 'block'),
            (r'\b(?i)(pointdetector|regiontally|meshtally)\s', token.Name, 'block'),
            (r'\b(?i)(src|meshsourcesaver)\s', token.Name, 'block'),
            (r'\b(?i)(importancemap|adjointsource|macromaterial)\s', token.Name, 'block'),
            (r'\b(?i)(fill)\s', token.Name, 'block'),
            (r'\b[0-9]+\s',token.Number),
            (r'([-+]?\d*\.?\d+)(?:[eE]([-+]?\d+))?\s',token.Number),
            (r'\"(.+?)\"', token.String),
            (r'\'(.+?)\'', token.String),
            (r'\”(.+?)\”', token.String),
            (r'\‘(.+?)\‘', token.String),
            (r'\“(.+?)\”', token.String),
            (r'\“(.+?)\"', token.String),
            (r'\”(.+?)\"', token.String),
            (r'\!.*\n', token.Comment),
            (r'(\w+|\n| )', token.Text),
            (r'(=|\-|\+|\%|\,|\‘|\$|\{|\}|\(|\)|\[|\]|\–|\_|\.|\…|\*|\,|\;|\:|\<|\>|\?|\/|\\)', token.Text),
            (r'\s+', token.Text),
            (r'.* ', token.Text)
        ],
        'block': [
            (r'(\n|[ ]{0,}\n)', token.Text,'#pop'),
            (r'[a-zA-Z]+\s', token.Name,'#pop'),
            (r'[0-9]+\s', token.Number,'#pop'),
            (r'\!.*\n', token.Comment,'#pop'),
            (r'.*\n', token.Text,'#pop'),
        ],
    }

################################################################################
def test():
    from pygments.styles import get_all_styles, STYLE_MAP
    styles = list(get_all_styles())
    print('style_maps: ', STYLE_MAP.keys())
    print('styles: ',styles)
################################################################################
if __name__ == "__main__":
    test()
################################################################################