-
Notifications
You must be signed in to change notification settings - Fork 1
/
conf.py
238 lines (190 loc) · 7.05 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
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
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
# 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 -----------------------------------------------------
import os
import re
import datetime as dt
project = 'Test Manual'
project = 'Test Manual'
copyright = ', Test'
author = 'Test Team'
github_user = 'stephanbracke'
github_repo = 'test-manual'
git_version_type = os.environ.get("READTHEDOCS_VERSION_TYPE") or 'local-dev'# tag, external, branch, unknown
git_branch_name = os.environ.get("READTHEDOCS_VERSION_NAME")
git_id = os.environ.get("READTHEDOCS_GIT_IDENTIFIER")
git_commit_hash = os.environ.get("READTHEDOCS_GIT_COMMIT_HASH")
if git_version_type == 'local-dev':
git_branch_name = re.sub('^v', '', os.popen('git branch --show-current').read().strip())
if(git_branch_name ==''):
git_id = re.sub('^v', '', os.popen('git describe').read().strip())
else:
git_id = re.sub('^v', '', os.popen('git rev-parse --short HEAD').read().strip())
git_commit_hash = git_id
print("---------------------------")
print(git_version_type)
print(git_branch_name)
print(git_id)
print(git_commit_hash)
print(re.sub('^v', '', os.popen('git describe').read().strip()))
print(re.sub('^v', '', os.popen('git describe --tags '+git_commit_hash).read().strip()))
print(re.sub('^v', '', os.popen('git describe --tags HEAD').read().strip()))
print("---------------------------")
def is_dev_stream() -> bool:
return (git_version_type == 'branch') and git_branch_name != 'latest'
def is_release() -> bool:
return git_version_type == 'tag'
def get_html_context():
if is_dev_stream():
return {
'display_github': True,
'github_user': github_user,
'github_repo': github_repo,
'github_version': git_branch_name+'/'
}
else:
return {}
def get_version_tag():
if is_release():
#current work around waiting for bugfix #11662 readthedocs.org
return re.sub('^v', '', os.popen('git describe --tags '+git_commit_hash).read().strip())
#return git_id
else:
return git_commit_hash[:7]
release = get_version_tag()
version = release
#release = re.sub('^v', '', os.popen('git describe').read().strip())
#release ='5.1.0-draft'
file_dir = os.path.dirname(os.path.realpath(__file__))
year = dt.datetime.now().year
copyright = str(year) + copyright
variables_to_export = [
"project",
"copyright",
"version",
]
frozen_locals = dict(locals())
rst_epilog = '\n'.join(map(lambda x: f".. |{x}| replace:: {frozen_locals[x]}", variables_to_export))
del frozen_locals
# -- General configuration ---------------------------------------------------
# Activate autosectionlabel plugin
# default_role = 'obj'
autosectionlabel_prefix_document = False
numfig = True
#navtree_shift = True
#navtree_root_links = True
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = ['sphinx_rtd_theme',
"sphinx.ext.viewcode"
#'sphinx.ext.imgmath',
#'sphinx.ext.autosectionlabel',
#'sphinx.ext.autodoc'
]
# Add any paths that contain templates here, relative to this directory.
# some comment
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.
exclude_patterns = ['_build','docs', 'Thumbs.db', '.DS_Store','venv','appendices/includes']
# -- Options for HTML output -------------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
#html_theme = 'alabaster'
html_theme = "sphinx_rtd_theme"
# 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']
html_css_files = ['theme_overrides.css',]
html_context = get_html_context()
latex_engine = 'xelatex'
latex_use_xindy = False
'''latex_appendices = ['appendices/terminology',
'appendices/observatories',
'appendices/archivedataformats',
'appendices/imagaddresses',
'appendices/dataformats',
'appendices/filters',
'appendices/acknowledgements'
]'''
preamble = r'''
\makeatletter
\fancypagestyle{normal}{
\fancyhf{}
\fancyfoot[LE,RO]{{\py@HeaderFamily\thepage}}
\fancyfoot[LO]{{\py@HeaderFamily\nouppercase{\leftmark}}}
\fancyfoot[RE]{{\py@HeaderFamily\nouppercase{\leftmark}}}
\fancyhead[LE,RO]{{\py@HeaderFamily \@title, \py@release}}
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0.4pt}
}
\usepackage{multicol}
\usepackage[none]{hyphenat}
\setlength\parindent{12pt}
\usepackage{enumitem}
\setlist{noitemsep}
\setlength{\parindent}{0cm}
'''
latex_maketitle = r'''
\pagenumbering{Roman} %%% to avoid page 1 conflict with actual page 1
\begin{titlepage}
\begin{figure}
\includegraphics[width = 1\textwidth,scale=1.2]{''' +file_dir + r'''/img/cover_intermagnet.png}
\end{figure}
\centering
\vspace{10mm}
\Huge \textbf{{INTERMAGNET}} \\
\vspace{5mm}
\Large \textbf{{Technical Reference Manual}} \\
\vspace{70mm}
\Large version : \ ''' + str(release) + ''' \ (''' + str(year) +r''')
\vspace*{0mm}
\break
\break
\break
\break
\break
\break
\end{titlepage}
\clearpage
\pagenumbering{roman}
'''
'''
#added to avoid empty pages
latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#
# 'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
#
# 'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
#
# 'preamble': '',
# Latex figure (float) alignment
#
# 'figure_align': 'htbp',
'printindex': '',
'preamble': preamble,
'maketitle':latex_maketitle
}
latex_documents = [
('index', 'technical_manual_'+release+'.tex',
u'INTERMAGNET Technical Reference Manual',
u'', 'manual'),
]'''