-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathconf.py
More file actions
95 lines (75 loc) · 3.65 KB
/
conf.py
File metadata and controls
95 lines (75 loc) · 3.65 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# SPDX-FileCopyrightText: Copyright (C) SchedMD LLC.
# SPDX-License-Identifier: Apache-2.0
# Configuration file for the Sphinx documentation builder.
#
# For the full list of built-in configuration values, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
project = 'slurm-bridge'
copyright = 'SchedMD'
author = 'SchedMD'
# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
extensions = ["myst_parser", "sphinx_design", "sphinx_copybutton", "sphinxmermaid", "sphinx_multiversion"]
myst_enable_extensions = ["colon_fence"]
myst_fence_as_directive = ["mermaid"]
templates_path = ['_templates']
exclude_patterns = []
# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
html_theme = "sphinx_rtd_theme"
html_logo = "_static/images/slinky.svg"
html_show_sourcelink = False
# -- Sphinx-multiversion configuration ---------------------------------------------------
# https://sphinx-contrib.github.io/multiversion/main/configuration.html#configuration
# Whitelist pattern for tags (set to None to ignore all tags)
smv_tag_whitelist = r'^v\d+\.\d+\.\d+$'
# Whitelist pattern for branches (set to None to ignore all branches)
smv_branch_whitelist = None
# Whitelist pattern for remotes (set to None to use local branches only)
smv_remote_whitelist = None
# Pattern for released versions
smv_released_pattern = r'^v\d+\.\d+\.\d+$'
# Format for versioned output directories inside the build directory
smv_outputdir_format = '{ref.name}'
# Determines whether remote or local git branches/tags are preferred if their output dirs conflict
smv_prefer_remote_refs = False
# Issue https://github.com/executablebooks/MyST-Parser/issues/845
# GitHub admonitions with Sphinx/MyST
# Workaround template adapted from (with some changes):
# https://github.com/python-project-templates/yardang/blob/f77348d45dcf0eb130af304f79c0bfb92ab90e0c/yardang/conf.py.j2#L156-L188
_GITHUB_ADMONITIONS = {
"> [!NOTE]": "note",
"> [!TIP]": "tip",
"> [!IMPORTANT]": "important",
"> [!WARNING]": "warning",
"> [!CAUTION]": "caution",
}
def run_convert_github_admonitions_to_rst(app, filename, lines):
# loop through lines, replace github admonitions
for i, orig_line in enumerate(lines):
orig_line_splits = orig_line.split("\n")
replacing = False
for j, line in enumerate(orig_line_splits):
# look for admonition key
for admonition_key in _GITHUB_ADMONITIONS:
if admonition_key in line:
line = line.replace(admonition_key, ":::{" + _GITHUB_ADMONITIONS[admonition_key] + "}\n")
# start replacing quotes in subsequent lines
replacing = True
break
else:
# replace indent to match directive
if replacing and "> " in line:
line = line.replace("> ", " ")
elif replacing:
# missing "> ", so stop replacing and terminate directive
line = f"\n:::\n{line}"
replacing = False
# swap line back in splits
orig_line_splits[j] = line
# swap line back in original
lines[i] = "\n".join(orig_line_splits)
def setup(app):
app.connect("source-read", run_convert_github_admonitions_to_rst)