This repository has been archived by the owner on Oct 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 55
/
conf.py
57 lines (46 loc) · 1.55 KB
/
conf.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import json
import os
import sys
import subprocess
from os import getenv
#support for modified code block
from pygments.lexers.shell import BashSessionLexer
from sphinx.highlighting import lexers
sys.path.append(os.path.abspath("./docs/sphinx_ext"))
#############
#
# Add a special lexer to add a class to console lexer
#
#############
def setup(app):
app.add_css_file("override.css")
class copyAllConsole (BashSessionLexer):
name = 'ShellSession'
lexers['ShellSession'] = copyAllConsole(startinLine=True)
# Get settings from conf.json
with open('conf.json') as jsonFile:
conf = json.load(jsonFile)
for item in conf:
globals()[item] = (conf[item])
# Dynamically determine the major version based on the branch name:
# vx.y for release-x.y, "devel" for everything else
branch = subprocess.check_output("git rev-parse --abbrev-ref HEAD".split(), encoding="utf-8")
if branch.startswith("release-"):
version = "v" + branch[len("release-"):].strip()
else:
version = "devel"
release = version
sphinx_md_useGitHubURL = True
baseBranch = "devel"
commitSHA = getenv('GITHUB_SHA')
githubBaseURL = 'https://github.com/' + (getenv('GITHUB_REPOSITORY') or 'intel/pmem-csi') + '/'
githubFileURL = githubBaseURL + "blob/"
githubDirURL = githubBaseURL + "tree/"
if commitSHA:
githubFileURL = githubFileURL + commitSHA + "/"
githubDirURL = githubDirURL + commitSHA + "/"
else:
githubFileURL = githubFileURL + baseBranch + "/"
githubDirURL = githubDirURL + baseBranch + "/"
sphinx_md_githubFileURL = githubFileURL
sphinx_md_githubDirURL = githubDirURL