-
Notifications
You must be signed in to change notification settings - Fork 42
/
Copy pathconf.py
248 lines (193 loc) · 7.74 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
237
238
239
240
241
242
243
244
245
246
247
248
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Lightning documentation build configuration file.
#
# This file is execfile()d with the current directory set to its
# containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All configuration values have a default; values that are commented out
# serve to show the default.
import sys, os, re, inspect
from unittest.mock import MagicMock
from pathlib import Path
import subprocess
import json
# 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.
sys.path.insert(0, os.path.abspath(""))
sys.path.insert(0, os.path.abspath("."))
sys.path.insert(0, os.path.abspath("_ext"))
sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath("doc")), "doc"))
# For obtaining all relevant C++ source files
currdir = Path(__file__).resolve().parent # PROJECT_SOURCE_DIR/docs
PROJECT_SOURCE_DIR = currdir.parent
CPP_SOURCE_DIR = PROJECT_SOURCE_DIR.joinpath("pennylane_lightning/core/src")
CPP_EXCLUDE_DIRS = ["tests", "benchmarks"] # relative to CPP_SOURCE_DIR
def obtain_cpp_files():
script_path = PROJECT_SOURCE_DIR.joinpath("bin/cpp-files")
if not script_path.exists():
print("The project directory structure is corrupted.")
sys.exit(1)
exclude_dirs = [CPP_SOURCE_DIR.joinpath(exclude_dir) for exclude_dir in CPP_EXCLUDE_DIRS]
p = subprocess.run(
[str(script_path), "--header-only", CPP_SOURCE_DIR, "--exclude-dirs", *exclude_dirs],
capture_output=True,
)
file_list = json.loads(p.stdout)
file_list = ["../" + str(Path(f).relative_to(PROJECT_SOURCE_DIR)) for f in file_list]
return file_list
CPP_FILES = obtain_cpp_files()
print(CPP_FILES)
class Mock(MagicMock):
__name__ = "foo"
@classmethod
def __getattr__(cls, name):
return MagicMock()
MOCK_MODULES = ["pennylane_lightning.lightning_qubit_ops",
"pennylane_lightning.lightning_qubit_ops.algorithms"]
mock = Mock()
for mod_name in MOCK_MODULES:
sys.modules[mod_name] = mock
# -- General configuration ------------------------------------------------
# If your documentation needs a minimal Sphinx version, state it here.
needs_sphinx = "3.3"
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
"breathe",
"exhale",
"sphinx.ext.autodoc",
"sphinx.ext.autosummary",
"sphinx.ext.coverage",
"sphinx.ext.graphviz",
"sphinx.ext.inheritance_diagram",
"sphinx.ext.intersphinx",
"sphinx.ext.mathjax",
"sphinx.ext.napoleon",
"sphinx.ext.todo",
"sphinx.ext.viewcode",
"sphinx_automodapi.automodapi",
"sphinx_automodapi.smart_resolver",
"sphinxext.opengraph",
]
# Open Graph metadata
ogp_social_cards = {
"image": "_static/logo.png",
"enable": True,
"site_url": "https://docs.pennylane.ai/projects/lightning/",
"line_color": "#03b2ff",
}
ogp_image = "_static/pennylane_lightning.png"
# The base URL with a proper language and version.
html_baseurl = os.environ.get("READTHEDOCS_CANONICAL_URL", "/")
intersphinx_mapping = {"https://docs.pennylane.ai/en/stable/": None}
autosummary_generate = True
autosummary_imported_members = False
automodapi_toctreedirnm = "code/api"
automodsumm_inherited_members = True
# Breathe extension
breathe_projects = {"Lightning-Qubit": "./doxyoutput/xml"}
breathe_default_project = "Lightning-Qubit"
mathjax_path = (
"https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML"
)
# Exhale extension
# Setup the exhale extension
exhale_args = {
# These arguments are required
"containmentFolder": "./api",
"rootFileName": "library_root.rst",
"rootFileTitle": "Overview",
"doxygenStripFromPath": "..",
# Suggested optional arguments
"createTreeView": True,
# TIP: if using the sphinx-bootstrap-theme, you need
# "treeViewIsBootstrap": True,
"exhaleExecutesDoxygen": True,
"exhaleDoxygenStdin": ("INPUT = " + " ".join(CPP_FILES) + "\nEXCLUDE_SYMBOLS = std::* "),
"afterTitleDescription": inspect.cleandoc(
"""
The Pennylane Lightning C++ API is intended to be called from Python through Pybind11. Direct use of the C++ API is currently unsupported and is provided for reference only.
"""
),
}
# Add any paths that contain templates here, relative to this directory.
from pennylane_sphinx_theme import templates_dir
templates_path = [templates_dir()]
# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
source_suffix = ".rst"
# The master toctree document.
master_doc = "index"
# General information about the project.
project = "Lightning"
copyright = "2023, Xanadu Quantum Technologies"
author = "Xanadu Inc."
add_module_names = False
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
from pennylane_lightning import lightning_qubit
# The full version, including alpha/beta/rc tags.
release = lightning_qubit.__version__
# The short X.Y version.
version = re.match(r"^(\d+\.\d+)", release).expand(r"\1")
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None
# today_fmt is used as the format for a strftime call.
today_fmt = "%Y-%m-%d"
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This patterns also effect to html_static_path and html_extra_path
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
nbsphinx_execute = "never"
# If true, sectionauthor and moduleauthor directives will be shown in the
# output. They are ignored by default.
show_authors = True
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = "sphinx"
# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = True
# -- Options for HTML output ----------------------------------------------
# The name of an image file (relative to this directory) to use as a favicon of
# the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
html_favicon = "_static/favicon.ico"
# 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 = [
"css/custom.css",
]
# -- html theme ---------------------------------------------------------
html_theme = "pennylane"
# html theme options (see theme.conf for more information)
html_theme_options = {
"navbar_name": "Lightning",
"navbar_active_link": 3,
"google_analytics_tracking_id": "G-C480Z9JL0D",
"extra_copyrights": [
"TensorFlow, the TensorFlow logo, and any related marks are trademarks of Google Inc."
],
"toc_overview": True,
}
edit_on_github_project = "PennyLaneAI/pennylane-lightning"
edit_on_github_branch = "master/doc"
# ============================================================
# the order in which autodoc lists the documented members
autodoc_member_order = "bysource"
# inheritance_diagram graphviz attributes
inheritance_node_attrs = dict(color="lightskyblue1", fillcolor="lightskyblue1", style="filled")
# autodoc_default_flags = ['members']
autosummary_generate = True