forked from Qiskit/qiskit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconf.py
More file actions
250 lines (199 loc) · 9.3 KB
/
conf.py
File metadata and controls
250 lines (199 loc) · 9.3 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
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
237
238
239
240
241
242
243
244
245
246
247
248
249
250
# This code is part of Qiskit.
#
# (C) Copyright IBM 2018.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative works of this code must retain this
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.
# pylint: disable=invalid-name,missing-function-docstring
"""Sphinx documentation builder."""
import datetime
import doctest
import os
import subprocess
project = "Qiskit"
project_copyright = f"2017-{datetime.date.today().year}, Qiskit Development Team"
author = "Qiskit Development Team"
# The short X.Y version
version = "0.45"
# The full version, including alpha/beta/rc tags
release = "0.45.0"
# The language for content autogenerated by Sphinx or the default for gettext content translation.
language = "en"
# For 'qiskit_sphinx_theme' tells it we're based at 'https://qiskit.org/<docs_url_prefix>'.
# Should not include the subdirectory for the stable version.
docs_url_prefix = "documentation"
rst_prolog = f".. |version| replace:: {version}"
extensions = [
"sphinx.ext.napoleon",
"sphinx.ext.autodoc",
"sphinx.ext.autosummary",
"sphinx.ext.mathjax",
"sphinx.ext.viewcode",
"sphinx.ext.extlinks",
"sphinx.ext.intersphinx",
"sphinx.ext.doctest",
"reno.sphinxext",
"sphinx_design",
"matplotlib.sphinxext.plot_directive",
"qiskit_sphinx_theme",
"nbsphinx",
]
templates_path = ["_templates"]
# Number figures, tables and code-blocks if they have a caption.
numfig = True
# Available keys are 'figure', 'table', 'code-block' and 'section'. '%s' is the number.
numfig_format = {"table": "Table %s"}
# Translations configuration.
translations_list = [
("en", "English"),
("bn_BN", "Bengali"),
("fr_FR", "French"),
("de_DE", "German"),
("ja_JP", "Japanese"),
("ko_KR", "Korean"),
("pt_UN", "Portuguese"),
("es_UN", "Spanish"),
("ta_IN", "Tamil"),
]
locale_dirs = ["locale/"]
gettext_compact = False
# Relative to source directory, affects general discovery, and html_static_path and html_extra_path.
exclude_patterns = ["_build", "**.ipynb_checkpoints"]
pygments_style = "colorful"
panels_css_variables = {
"tabs-color-label-active": "rgb(138, 63, 252)",
"tabs-color-label-inactive": "rgb(221, 225, 230)",
}
# This adds the module name to e.g. function API docs. We use the default of True because our
# module pages sometimes have functions from submodules on the page, and we want to make clear
# that you must include the submodule to import it. We should strongly consider reorganizing our
# code to avoid this, i.e. re-exporting the submodule members from the top-level module. Once fixed
# and verified by only having a single `.. currentmodule::` in the file, we can turn this back to
# False.
add_module_names = True
# A list of prefixes that are ignored for sorting the Python module index
# (e.g., if this is set to ['foo.'], then foo.bar is shown under B, not F).
modindex_common_prefix = ["qiskit."]
# ----------------------------------------------------------------------------------
# Extlinks
# ----------------------------------------------------------------------------------
# Refer to https://www.sphinx-doc.org/en/master/usage/extensions/extlinks.html
extlinks = {
"pull_terra": ("https://github.com/Qiskit/qiskit-terra/pull/%s", "qiskit-terra #%s"),
"pull_aer": ("https://github.com/Qiskit/qiskit-aer/pull/%s", "qiskit-aer #%s"),
"pull_ibmq-provider": (
"https://github.com/Qiskit/qiskit-ibmq-provider/pull/%s",
"qiskit-ibmq-provider #%s",
),
}
intersphinx_mapping = {
"rustworkx": ("https://qiskit.org/ecosystem/rustworkx/", None),
"qiskit-ibm-runtime": ("https://qiskit.org/ecosystem/ibm-runtime/", None),
"qiskit-aer": ("https://qiskit.org/ecosystem/aer/", None),
"numpy": ("https://numpy.org/doc/stable/", None),
"matplotlib": ("https://matplotlib.org/stable/", None),
}
# ----------------------------------------------------------------------------------
# HTML theme
# ----------------------------------------------------------------------------------
html_theme = "qiskit"
html_favicon = "images/favicon.ico"
html_last_updated_fmt = "%Y/%m/%d"
html_context = {
"analytics_enabled": bool(os.getenv("QISKIT_ENABLE_ANALYTICS", ""))
} # enable segment analytics for qiskit.org/documentation
html_static_path = ["_static"]
# ----------------------------------------------------------------------------------
# Autodoc
# ----------------------------------------------------------------------------------
# Note that setting autodoc defaults here may not have as much of an effect as you may expect; any
# documentation created by autosummary uses a template file (in autosummary in the templates path),
# which likely overrides the autodoc defaults.
# Move type hints from signatures to the parameter descriptions (except in overload cases, where
# that's not possible).
autodoc_typehints = "description"
# Only add type hints from signature to description body if the parameter has documentation. The
# return type is always added to the description (if in the signature).
autodoc_typehints_description_target = "documented_params"
autoclass_content = "both"
autosummary_generate = True
autosummary_generate_overwrite = False
# The pulse library contains some names that differ only in capitalisation, during the changeover
# surrounding SymbolPulse. Since these resolve to autosummary filenames that also differ only in
# capitalisation, this causes problems when the documentation is built on an OS/filesystem that is
# enforcing case-insensitive semantics. This setting defines some custom names to prevent the clash
# from happening.
autosummary_filename_map = {
"qiskit.pulse.library.Constant": "qiskit.pulse.library.Constant_class.rst",
"qiskit.pulse.library.Sawtooth": "qiskit.pulse.library.Sawtooth_class.rst",
"qiskit.pulse.library.Triangle": "qiskit.pulse.library.Triangle_class.rst",
"qiskit.pulse.library.Cos": "qiskit.pulse.library.Cos_class.rst",
"qiskit.pulse.library.Sin": "qiskit.pulse.library.Sin_class.rst",
"qiskit.pulse.library.Gaussian": "qiskit.pulse.library.Gaussian_class.rst",
"qiskit.pulse.library.Drag": "qiskit.pulse.library.Drag_class.rst",
"qiskit.pulse.library.Square": "qiskit.pulse.library.Square_fun.rst",
"qiskit.pulse.library.Sech": "qiskit.pulse.library.Sech_fun.rst",
}
# We only use Google-style docstrings, and allowing Napoleon to parse Numpy-style docstrings both
# slows down the build (a little) and can sometimes result in _regular_ section headings in
# module-level documentation being converted into surprising things.
napoleon_google_docstring = True
napoleon_numpy_docstring = False
# ----------------------------------------------------------------------------------
# Doctest
# ----------------------------------------------------------------------------------
doctest_default_flags = (
doctest.ELLIPSIS
| doctest.NORMALIZE_WHITESPACE
| doctest.IGNORE_EXCEPTION_DETAIL
| doctest.DONT_ACCEPT_TRUE_FOR_1
)
# Leaving this string empty disables testing of doctest blocks from docstrings.
# Doctest blocks are structures like this one:
# >> code
# output
doctest_test_doctest_blocks = ""
# ----------------------------------------------------------------------------------
# Plot directive
# ----------------------------------------------------------------------------------
plot_html_show_formats = False
# ----------------------------------------------------------------------------------
# Nbsphinx
# ----------------------------------------------------------------------------------
nbsphinx_timeout = int(os.getenv("QISKIT_CELL_TIMEOUT", "300"))
nbsphinx_execute = os.getenv("QISKIT_DOCS_BUILD_TUTORIALS", "never")
nbsphinx_widgets_path = ""
nbsphinx_thumbnails = {"**": "_static/images/logo.png"}
nbsphinx_prolog = """
{% set docname = env.doc2path(env.docname, base=None) %}
.. only:: html
.. role:: raw-html(raw)
:format: html
.. note::
This page was generated from `{{ docname }}`__.
__ https://github.com/Qiskit/qiskit-terra/blob/main/{{ docname }}
"""
def add_versions_to_config(_app, config):
"""Add a list of old documentation versions that should have links generated to them into the
context, so the theme can use them to generate a sidebar."""
# First 0.x version where Qiskit/Terra and the metapackage aligned on number.
first_unified_zero_minor = 45
# Start with the hardcoded versions of the documentation that were managed while the metapackage
# still existed, so are based on tags that don't exist in the Qiskit package repo.
versions = ["0.19"] + [f"0.{x}" for x in range(24, first_unified_zero_minor)]
proc = subprocess.run(["git", "describe", "--abbrev=0"], capture_output=True, check=True)
current_version = proc.stdout.decode("utf8")
current_version_info = current_version.split(".")
if current_version_info[0] != "0":
raise Exception("TODO: handle major versions")
versions.extend(
f"0.{x}" % x for x in range(first_unified_zero_minor, int(current_version_info[1]) + 1)
)
config.html_context["version_list"] = versions
def setup(app):
app.connect("config-inited", add_versions_to_config)