-
Notifications
You must be signed in to change notification settings - Fork 57
/
replacements.py
29 lines (25 loc) · 1.07 KB
/
replacements.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
def variableReplace(app, docname, source):
"""
Takes the source on rst and replaces all the needed variables declared on
variable_replacements structure
"""
result = source[0]
for key in app.config.variable_replacements:
result = result.replace(key, app.config.variable_replacements[key])
source[0] = result
# Add the needed variables to be replaced either on code or on text on the next
# dictionary structure.
variable_replacements = {
"{InstallationVersion}" : "3.8.5",
"\{admindocs\}" : "https://singularity.hpcng.org/admin-docs/3.8",
"\{version\}": "3.8",
"\{adminversion\}": "3.8",
# The 'Singularity' noun is now a replacement so we can have
# {Singularity} rather than bare 'Singularity'... and HPCng can
# replace to SingularityPRO so that it is clearer where docs
# diverge a bit from Singularity<->SingularityPRO due to long-term backports etc.
"{Singularity}": "Singularity",
}
def setup(app):
app.add_config_value('variable_replacements', {}, True)
app.connect('source-read', variableReplace)