forked from Qiskit/rustworkx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconf.py
154 lines (115 loc) · 3.73 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
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# retworkx documentation build configuration file
#
import sys, os
import subprocess
# General configuration:
project = u'retworkx'
copyright = u'2021, retworkx Contributors'
# The short X.Y version.
version = '0.11.0'
# The full version, including alpha/beta/rc tags.
release = '0.11.0'
extensions = ['sphinx.ext.autodoc',
'sphinx.ext.autosummary',
'sphinx.ext.viewcode',
'sphinx.ext.extlinks',
'sphinx.ext.todo',
'sphinx.ext.viewcode',
'm2r2',
'jupyter_sphinx',
'reno.sphinxext',
'sphinx.ext.intersphinx',
]
html_static_path = ['_static']
templates_path = ['_templates']
html_css_files = ['style.css', 'custom.css']
pygments_style = 'colorful'
add_module_names = False
modindex_common_prefix = ['retworkx.']
todo_include_todos = True
source_suffix = ['.rst', '.md']
master_doc = 'index'
# Autosummary options
autosummary_generate = True
autosummary_generate_overwrite = False
autoclass_content = 'both'
# Intersphinx configuration
intersphinx_mapping = {
'matplotlib': ('https://matplotlib.org/stable/', None),
'numpy': ('http://docs.scipy.org/doc/numpy/', None)
}
# Prepend warning for development docs:
if not os.getenv('RETWORKX_DEV_DOCS', None):
rst_prolog = """
.. raw:: html
<br><br><br>
""".format(release)
else:
rst_prolog = """
.. raw:: html
<br><br><br>
.. note::
This is the documnetation for the current state of the development branch
of retworkx. The documentation or APIs here can change prior to being
released.
"""
# HTML Output Options
html_theme = 'qiskit_sphinx_theme'
html_theme_options = {
'logo_only': False,
'display_version': True,
'prev_next_buttons_location': 'bottom',
'style_external_links': True,
}
htmlhelp_basename = 'retworkx'
# Latex options
latex_elements = {}
latex_documents = [
('index', 'retworkx.tex', u'retworkx Documentation',
u'retworkx Contributors', 'manual'),
]
# Texinfo options
texinfo_documents = [
('index', 'retworkx', u'retworkx Documentation',
u'retworkx Contributors', 'retworkx', '',
'Miscellaneous'),
]
# Version extensions
def _get_versions(app, config):
context = config.html_context
start_version = (0, 8, 0)
proc = subprocess.run(['git', 'describe', '--abbrev=0'],
capture_output=True)
proc.check_returncode()
current_version = proc.stdout.decode('utf8')
current_version_info = current_version.split('.')
if current_version_info[0] == '0':
version_list = [
'0.%s' % x for x in range(start_version[1],
int(current_version_info[1]) + 1)]
else:
#TODO: When 1.0.0 add code to handle 0.x version list
version_list = []
pass
context['version_list'] = version_list
context['version_label'] = _get_version_label(current_version)
def _get_version_label(current_version):
if not os.getenv('RETWORKX_DEV_DOCS', None):
current_version_info = current_version.split('.')
return ".".join(current_version_info[:-1])
else:
return "Development"
def setup(app):
app.connect('config-inited', _get_versions)