-
Notifications
You must be signed in to change notification settings - Fork 15
/
replacements.py
38 lines (33 loc) · 1.28 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
30
31
32
33
34
35
36
37
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 = {
# This is used in install instructions, so should be a full version
"{InstallationVersion}" : "1.3.5",
# This should be the same as the above except with any hyphen before
# a release candidate replaced with dot, and an additional hyphen and
# release number added
"{GitHubDownloadVersion}" : "1.3.5-1",
"{userdocs}" : "https://apptainer.org/docs/user/main",
"{adminversion}": "main",
"{userversion}": "main",
"{Project}": "Apptainer",
"{AProject}": "An Apptainer",
"{aProject}": "an Apptainer",
"{command}": "apptainer",
"{ENVPREFIX}": "APPTAINER",
"{orgrepo}": "apptainer/apptainer",
"{repobranch}": "main",
}
def setup(app):
app.add_config_value('variable_replacements', {}, True)
app.connect('source-read', variableReplace)
app.add_css_file('custom.css')