Diff of /docs/conf.py [000000] .. [c36663]

Switch to unified view

a b/docs/conf.py
1
#!/usr/bin/env python3
2
# -*- coding: utf-8 -*-
3
#
4
# Braindecode documentation build configuration file, created by
5
# sphinx-quickstart on Sat Jul  1 01:51:38 2017.
6
#
7
# This file is execfile()d with the current directory set to its
8
# containing dir.
9
#
10
# Note that not all possible configuration values are present in this
11
# autogenerated file.
12
#
13
# All configuration values have a default; values that are commented out
14
# serve to show the default.
15
16
# If extensions (or modules to document with autodoc) are in another directory,
17
# add these directories to sys.path here. If the directory is relative to the
18
# documentation root, use os.path.abspath to make it absolute, like shown here.
19
20
import inspect
21
import os
22
import os.path as op
23
import sys
24
25
import matplotlib
26
27
matplotlib.use("agg")
28
import faulthandler
29
from datetime import datetime, timezone
30
31
import sphinx_gallery  # noqa
32
from numpydoc import docscrape, numpydoc  # noqa
33
from sphinx_gallery.sorting import ExplicitOrder, FileNameSortKey
34
35
# -- General configuration ------------------------------------------------
36
37
# If your documentation needs a minimal Sphinx version, state it here.
38
needs_sphinx = "2.0"
39
40
curdir = os.path.dirname(__file__)
41
sys.path.append(os.path.abspath(os.path.join(curdir, "..", "braindecode")))
42
sys.path.append(os.path.abspath(os.path.join(curdir, "sphinxext")))
43
44
# Add any Sphinx extension module names here, as strings. They can be
45
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
46
# ones.
47
extensions = [
48
    "sphinx.ext.autodoc",
49
    "sphinx.ext.autosummary",
50
    "sphinx.ext.doctest",
51
    "sphinx.ext.todo",
52
    "sphinx.ext.coverage",
53
    "sphinx.ext.mathjax",
54
    "sphinx.ext.ifconfig",
55
    "sphinx.ext.intersphinx",
56
    "sphinx.ext.githubpages",
57
    "sphinx.ext.napoleon",
58
    "sphinx_gallery.gen_gallery",
59
    "sphinx.ext.linkcode",
60
    "sphinx_design",
61
    "numpydoc",
62
    "gh_substitutions",
63
]
64
65
66
def linkcode_resolve(domain, info):
67
    """Determine the URL corresponding to a Python object.
68
69
    Parameters
70
    ----------
71
    domain : str
72
        Only useful when "py".
73
    info : dict
74
        With keys "module" and "fullname".
75
76
    Returns
77
    -------
78
    url : str
79
        The code URL.
80
81
    Notes
82
    -----
83
    This has been adapted to deal with our "verbose" decorator.
84
    Adapted from SciPy (doc/source/conf.py).
85
    """
86
    repo = "https://github.com/braindecode/braindecode/"
87
    if domain != "py":
88
        return None
89
    if not info["module"]:
90
        return None
91
92
    modname = info["module"]
93
    fullname = info["fullname"]
94
95
    submod = sys.modules.get(modname)
96
    if submod is None:
97
        return None
98
99
    obj = submod
100
    for part in fullname.split("."):
101
        try:
102
            obj = getattr(obj, part)
103
        except Exception:
104
            return None
105
106
    try:
107
        fn = inspect.getsourcefile(obj)
108
    except Exception:
109
        fn = None
110
    if not fn:
111
        try:
112
            fn = inspect.getsourcefile(sys.modules[obj.__module__])
113
        except Exception:
114
            fn = None
115
    if not fn:
116
        return None
117
    fn = op.relpath(fn, start=op.dirname(braindecode.__file__))
118
    fn = "/".join(op.normpath(fn).split(os.sep))  # in case on Windows
119
120
    try:
121
        source, lineno = inspect.getsourcelines(obj)
122
    except Exception:
123
        lineno = None
124
125
    if lineno:
126
        linespec = "#L%d-L%d" % (lineno, lineno + len(source) - 1)
127
    else:
128
        linespec = ""
129
130
    return f"{repo}/blob/master/braindecode/{fn}{linespec}"
131
132
133
# -- Options for sphinx gallery --------------------------------------------
134
faulthandler.enable()
135
os.environ["_BRAINDECODE_BROWSER_NO_BLOCK"] = "true"
136
os.environ["BRAINDECODE_BROWSER_OVERVIEW_MODE"] = "hidden"
137
os.environ["BRAINDECODE_BROWSER_THEME"] = "light"
138
139
# -- Path setup --------------------------------------------------------------
140
141
# If extensions (or modules to document with autodoc) are in another directory,
142
# add these directories to sys.path here. If the directory is relative to the
143
# documentation root, use os.path.abspath to make it absolute, like shown here.
144
curdir = os.path.dirname(__file__)
145
sys.path.append(os.path.abspath(os.path.join(curdir, "..", "mne")))
146
sys.path.append(os.path.abspath(os.path.join(curdir, "sphinxext")))
147
148
autosummary_generate = True
149
autodoc_default_options = {"inherited-members": False}
150
151
numpydoc_show_class_members = False
152
153
exclude_patterns = ["_build", "_templates"]
154
155
# Add any paths that contain templates here, relative to this directory.
156
templates_path = ["_templates"]
157
158
# The suffix(es) of source filenames.
159
# You can specify multiple suffix as a list of string:
160
#
161
# source_suffix = ['.rst', '.md']
162
source_suffix = ".rst"
163
164
# The master toctree document.
165
master_doc = "index"
166
167
# General information about the project.
168
169
170
# -- Project information -----------------------------------------------------
171
172
project = "Braindecode"
173
td = datetime.now(tz=timezone.utc)
174
175
# We need to triage which date type we use so that incremental builds work
176
# (Sphinx looks at variable changes and rewrites all files if some change)
177
copyright = (
178
    f'2012–{td.year}, Braindecode Developers. Last updated <time datetime="{td.isoformat()}" class="localized">{td.strftime("%Y-%m-%d %H:%M %Z")}</time>\n'  # noqa: E501
179
    '<script type="text/javascript">$(function () { $("time.localized").each(function () { var el = $(this); el.text(new Date(el.attr("datetime")).toLocaleString([], {dateStyle: "medium", timeStyle: "long"})); }); } )</script>'
180
)  # noqa: E501
181
if os.getenv("BRAINDECODE_FULL_DATE", "false").lower() != "true":
182
    copyright = f"2018–{td.year}, Braindecode Developers."
183
184
author = "Braindecode developers"
185
186
# The version info for the project you're documenting, acts as replacement for
187
# |version| and |release|, also used in various other places throughout the
188
# built documents.
189
#
190
# The short X.Y version.
191
import braindecode
192
193
release = braindecode.__version__
194
# The full version, including alpha/beta/rc tags.
195
version = ".".join(release.split(".")[:2])
196
197
# The language for content autogenerated by Sphinx. Refer to documentation
198
# for a list of supported languages.
199
#
200
# This is also used if you do content translation via gettext catalogs.
201
# Usually you set "language" from the command line for these cases.
202
# language = None
203
204
# List of patterns, relative to source directory, that match files and
205
# directories to ignore when looking for source files.
206
# This patterns also effect to html_static_path and html_extra_path
207
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
208
209
# The name of the Pygments (syntax highlighting) style to use.
210
pygments_style = "sphinx"
211
212
# If true, `todo` and `todoList` produce output, else they produce nothing.
213
todo_include_todos = True
214
215
# Sphinx-gallery configuration
216
217
# Example configuration for intersphinx: refer to the Python standard library.
218
intersphinx_mapping = {
219
    "python": ("https://docs.python.org/{.major}".format(sys.version_info), None),
220
    "numpy": ("https://docs.scipy.org/doc/numpy/", None),
221
    "scipy": ("https://docs.scipy.org/doc/scipy/reference", None),
222
    "matplotlib": ("https://matplotlib.org/", None),
223
    "sklearn": ("http://scikit-learn.org/stable", None),
224
    "mne": ("http://mne.tools/stable", None),
225
    "skorch": ("https://skorch.readthedocs.io/en/stable/", None),
226
    "torch": ("https://pytorch.org/docs/stable/", None),
227
    "braindecode": ("https://braindecode.org/", None),
228
}
229
230
sphinx_gallery_conf = {
231
    "examples_dirs": ["../examples"],
232
    "gallery_dirs": ["auto_examples"],
233
    "doc_module": ("braindecode", "mne"),
234
    "backreferences_dir": "generated",
235
    "show_memory": True,
236
    "reference_url": dict(braindecode=None),
237
    "subsection_order": ExplicitOrder(
238
        [
239
            "../examples/model_building",
240
            "../examples/datasets_io",
241
            "../examples/advanced_training",
242
            "../examples/applied_examples",
243
        ]
244
    ),
245
    "within_subsection_order": FileNameSortKey,
246
}
247
248
# -- Options for HTML output ----------------------------------------------
249
250
# The theme to use for HTML and HTML Help pages.  See the documentation for
251
# a list of builtin themes.
252
#
253
import sphinx_rtd_theme  # noqa
254
255
html_theme = "pydata_sphinx_theme"
256
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
257
switcher_version_match = "dev" if release.endswith("dev0") else version
258
# Theme options are theme-specific and customize the look and feel of a theme
259
# further.  For a list of options available for each theme, see the
260
# documentation.
261
262
html_theme_options = {
263
    "icon_links": [
264
        {
265
            "name": "GitHub",
266
            "url": "https://github.com/braindecode/braindecode",
267
            "icon": "fa-brands fa-github",
268
        },
269
    ],
270
    "github_url": "https://github.com/braindecode/braindecode",
271
    "icon_links_label": "External Links",  # for screen reader
272
    "use_edit_page_button": False,
273
    "navigation_with_keys": False,
274
    "collapse_navigation": False,
275
    "header_links_before_dropdown": 6,
276
    "navigation_depth": 6,
277
    "show_toc_level": 1,
278
    "navbar_end": ["theme-switcher", "version-switcher"],
279
    "switcher": {
280
        "json_url": "https://braindecode.org/stable/_static/versions.json",
281
        "version_match": switcher_version_match,
282
    },
283
    "logo": {
284
        "image_light": "_static/braindecode_symbol.png",
285
        "image_dark": "_static/braindecode_symbol.png",
286
        "alt_text": "Braindecode Logo",
287
    },
288
    "footer_start": ["copyright"],
289
    # 'pygment_light_style': 'default',
290
    "analytics": dict(google_analytics_id="G-7Q43R82K6D"),
291
}
292
293
# The name of an image file (relative to this directory) to place at the top
294
# of the sidebar.
295
html_logo = "_static/braindecode_symbol.png"
296
297
# Add any paths that contain custom static files (such as style sheets) here,
298
# relative to this directory. They are copied after the builtin static files,
299
# so a file named "default.css" will overwrite the builtin "default.css".
300
html_static_path = ["_static"]
301
html_css_files = [
302
    "style.css",
303
]
304
305
# If true, links to the reST sources are added to the pages.
306
html_show_sourcelink = False
307
html_copy_source = False
308
309
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
310
html_show_sphinx = False
311
312
# -- Options for HTMLHelp output ------------------------------------------
313
314
# Output file base name for HTML help builder.
315
htmlhelp_basename = "Braindecode-doc"
316
317
# accommodate different logo shapes (width values in rem)
318
xs = "2"
319
sm = "2.5"
320
md = "3"
321
lg = "4.5"
322
xl = "5"
323
xxl = "6"
324
325
html_context = {
326
    "build_dev_html": bool(int(os.environ.get("BUILD_DEV_HTML", False))),
327
    "default_mode": "light",
328
    "pygment_light_style": "tango",
329
    "pygment_dark_style": "native",
330
    "icon_links_label": "Quick Links",  # for screen reader
331
    "show_toc_level": 1,
332
    "institutions": [
333
        dict(
334
            name="University of Freiburg",
335
            img="unifreiburg.png",
336
            url="https://www.ieeg.uni-freiburg.de/",
337
            size=lg,
338
        ),
339
        dict(
340
            name="Institut national de recherche en informatique et en automatique",  # noqa E501
341
            img="inria.png",
342
            url="https://www.inria.fr/",
343
            size=xl,
344
        ),
345
    ],
346
    "navbar_align": "content",
347
    "github_user": "braindecode",
348
    "github_repo": "braindecode",
349
    "github_version": "main",
350
    "doc_path": "docs",
351
}
352
353
html_sidebars = {
354
    "models_summary": [],
355
    "cite": [],
356
    "help": [],
357
    "whats_new": [],
358
}
359
360
# -- Options for LaTeX output ---------------------------------------------
361
362
latex_elements = {
363
    # The paper size ('letterpaper' or 'a4paper').
364
    #
365
    # 'papersize': 'letterpaper',
366
    # The font size ('10pt', '11pt' or '12pt').
367
    #
368
    # 'pointsize': '10pt',
369
    # Additional stuff for the LaTeX preamble.
370
    #
371
    # 'preamble': '',
372
    # Latex figure (float) alignment
373
    #
374
    # 'figure_align': 'htbp',
375
}
376
377
latex_logo = "_static/braindecode_symbol.png"
378
latex_toplevel_sectioning = "part"
379
380
# Grouping the document tree into LaTeX files. List of tuples
381
# (source start file, target name, title,
382
#  author, documentclass [howto, manual, or own class]).
383
latex_documents = [
384
    (
385
        master_doc,
386
        "Braindecode.tex",
387
        "Braindecode",
388
        "Robin Tibor Schirrmeister",
389
        "manual",
390
    ),
391
]
392
393
# -- Fontawesome support -----------------------------------------------------
394
395
# here the "fab" and "fas" refer to "brand" and "solid" (determines which font
396
# file to look in). "fw" indicates fixed width.
397
brand_icons = ("apple", "linux", "windows", "discourse", "python")
398
fixed_icons = (
399
    # homepage:
400
    "book",
401
    "code-branch",
402
    "newspaper",
403
    "question-circle",
404
    "quote-left",
405
    # contrib guide:
406
    "bug",
407
    "comment",
408
    "hand-sparkles",
409
    "magic",
410
    "pencil-alt",
411
    "remove-format",
412
    "universal-access",
413
    "discourse",
414
    "python",
415
)
416
other_icons = (
417
    "hand-paper",
418
    "question",
419
    "rocket",
420
    "server",
421
    "code",
422
    "desktop",
423
    "terminal",
424
    "cloud-download-alt",
425
    "wrench",
426
    "hourglass",
427
)
428
icons = dict()
429
for icon in brand_icons + fixed_icons + other_icons:
430
    font = ("fab" if icon in brand_icons else "fas",)  # brand or solid font
431
    fw = ("fa-fw",) if icon in fixed_icons else ()  # fixed-width
432
    icons[icon] = font + fw
433
434
prolog = ""
435
for icon, classes in icons.items():
436
    prolog += f"""
437
.. |{icon}| raw:: html
438
439
    <i class="{" ".join(classes)} fa-{icon}"></i>
440
"""
441
442
prolog += """
443
.. |fix-bug| raw:: html
444
445
    <span class="fa-stack small-stack">
446
        <i class="fas fa-bug fa-stack-1x"></i>
447
        <i class="fas fa-ban fa-stack-2x"></i>
448
    </span>
449
"""
450
451
prolog += """
452
.. |ensp| unicode:: U+2002 .. EN SPACE
453
"""
454
455
# -- Options for manual page output ---------------------------------------
456
457
# One entry per manual page. List of tuples
458
# (source start file, name, description, authors, manual section).
459
man_pages = [(master_doc, "braindecode", "Braindecode", [author], 1)]
460
461
# -- Options for Texinfo output -------------------------------------------
462
463
# Grouping the document tree into Texinfo files. List of tuples
464
# (source start file, target name, title, author,
465
#  dir menu entry, description, category)
466
texinfo_documents = [
467
    (
468
        master_doc,
469
        "Braindecode",
470
        "Braindecode",
471
        author,
472
        "Braindecode",
473
        "One line description of project.",
474
        "Miscellaneous",
475
    ),
476
]