-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
Copy pathconf.py
1713 lines (1605 loc) · 57.5 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
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
"""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
"""
# Authors: The MNE-Python contributors.
# License: BSD-3-Clause
# Copyright the MNE-Python contributors.
import faulthandler
import os
import subprocess
import sys
from datetime import datetime, timezone
from importlib.metadata import metadata
from pathlib import Path
import matplotlib
import sphinx
from intersphinx_registry import get_intersphinx_mapping
from numpydoc import docscrape
from sphinx.config import is_serializable
from sphinx.domains.changeset import versionlabels
from sphinx_gallery.sorting import ExplicitOrder
import mne
import mne.html_templates._templates
from mne.tests.test_docstring_parameters import error_ignores
from mne.utils import (
linkcode_resolve,
run_subprocess,
)
assert linkcode_resolve is not None # avoid flake warnings, used by numpydoc
matplotlib.use("agg")
faulthandler.enable()
os.environ["_MNE_BROWSER_NO_BLOCK"] = "true"
os.environ["MNE_BROWSER_OVERVIEW_MODE"] = "hidden"
os.environ["MNE_BROWSER_THEME"] = "light"
os.environ["MNE_3D_OPTION_THEME"] = "light"
# https://numba.readthedocs.io/en/latest/reference/deprecation.html#deprecation-of-old-style-numba-captured-errors # noqa: E501
os.environ["NUMBA_CAPTURED_ERRORS"] = "new_style"
mne.html_templates._templates._COLLAPSED = True # collapse info _repr_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.
curpath = Path(__file__).parent.resolve(strict=True)
sys.path.append(str(curpath / "sphinxext"))
from credit_tools import generate_credit_rst # noqa: E402
from mne_doc_utils import report_scraper, reset_warnings, sphinx_logger # noqa: E402
# -- Project information -----------------------------------------------------
project = "MNE"
td = datetime.now(tz=timezone.utc)
# We need to triage which date type we use so that incremental builds work
# (Sphinx looks at variable changes and rewrites all files if some change)
copyright = ( # noqa: A001
f'2012–{td.year}, MNE Developers. Last updated <time datetime="{td.isoformat()}" class="localized">{td.strftime("%Y-%m-%d %H:%M %Z")}</time>\n' # noqa: E501
'<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>' # noqa: E501
)
if os.getenv("MNE_FULL_DATE", "false").lower() != "true":
copyright = f"2012–{td.year}, MNE Developers. Last updated locally." # noqa: A001
# 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.
#
# The full version, including alpha/beta/rc tags.
release = mne.__version__
sphinx_logger.info(f"Building documentation for MNE {release} ({mne.__file__})")
# The short X.Y version.
version = ".".join(release.split(".")[:2])
# -- General configuration ---------------------------------------------------
# If your documentation needs a minimal Sphinx version, state it here.
needs_sphinx = "6.0"
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
# builtin
"sphinx.ext.autodoc",
"sphinx.ext.autosummary",
"sphinx.ext.coverage",
"sphinx.ext.doctest",
"sphinx.ext.graphviz",
"sphinx.ext.intersphinx",
"sphinx.ext.linkcode",
"sphinx.ext.mathjax",
"sphinx.ext.todo",
# contrib
"matplotlib.sphinxext.plot_directive",
"numpydoc",
"sphinx_copybutton",
"sphinx_design",
"sphinx_gallery.gen_gallery",
"sphinxcontrib.bibtex",
"sphinxcontrib.youtube",
"sphinxcontrib.towncrier.ext",
# homegrown
"contrib_avatars",
"gen_commands",
"gen_names",
"gh_substitutions",
"mne_substitutions",
"newcontrib_substitutions",
"unit_role",
"related_software",
]
# Add any paths that contain templates here, relative to this directory.
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.
# NB: changes here should also be made to the linkcheck target in the Makefile
exclude_patterns = ["_includes", "changes/devel"]
# The suffix of source filenames.
source_suffix = ".rst"
# The main toctree document.
master_doc = "index"
# List of documents that shouldn't be included in the build.
unused_docs = []
# List of directories, relative to source directory, that shouldn't be searched
# for source files.
exclude_trees = ["_build"]
# The reST default role (used for this markup: `text`) to use for all
# documents.
default_role = "py:obj"
# A list of ignored prefixes for module index sorting.
modindex_common_prefix = ["mne."]
# -- Sphinx-Copybutton configuration -----------------------------------------
copybutton_prompt_text = r">>> |\.\.\. |\$ "
copybutton_prompt_is_regexp = True
# -- sphinxcontrib-towncrier configuration -----------------------------------
towncrier_draft_working_directory = str(curpath.parent)
# -- Intersphinx configuration -----------------------------------------------
intersphinx_mapping = {
# More niche so didn't upstream to intersphinx_registry
"nitime": ("https://nipy.org/nitime/", None),
"mne_bids": ("https://mne.tools/mne-bids/stable", None),
"mne-connectivity": ("https://mne.tools/mne-connectivity/stable", None),
"mne-gui-addons": ("https://mne.tools/mne-gui-addons", None),
"picard": ("https://pierreablin.github.io/picard/", None),
"eeglabio": ("https://eeglabio.readthedocs.io/en/latest", None),
"pybv": ("https://pybv.readthedocs.io/en/latest", None),
}
intersphinx_mapping.update(
get_intersphinx_mapping(
packages=set(
"""
imageio matplotlib numpy pandas python scipy statsmodels sklearn numba joblib nibabel
seaborn patsy pyvista dipy nilearn pyqtgraph
""".strip().split()
),
)
)
# NumPyDoc configuration -----------------------------------------------------
# Define what extra methods numpydoc will document
docscrape.ClassDoc.extra_public_methods = mne.utils._doc_special_members
numpydoc_class_members_toctree = False
numpydoc_show_inherited_class_members = {
"mne.Forward": False,
"mne.Projection": False,
"mne.SourceSpaces": False,
}
numpydoc_attributes_as_param_list = True
numpydoc_xref_param_type = True
numpydoc_xref_aliases = {
# Python
"file-like": ":term:`file-like <python:file object>`",
"iterator": ":term:`iterator <python:iterator>`",
"path-like": ":term:`path-like`",
"array-like": ":term:`array_like <numpy:array_like>`",
"Path": ":class:`python:pathlib.Path`",
"bool": ":ref:`bool <python:typebool>`",
# Matplotlib
"colormap": ":ref:`colormap <matplotlib:colormaps>`",
"color": ":doc:`color <matplotlib:api/colors_api>`",
"Axes": "matplotlib.axes.Axes",
"Figure": "matplotlib.figure.Figure",
"Axes3D": "mpl_toolkits.mplot3d.axes3d.Axes3D",
"ColorbarBase": "matplotlib.colorbar.ColorbarBase",
# sklearn
"LeaveOneOut": "sklearn.model_selection.LeaveOneOut",
"MetadataRequest": "sklearn.utils.metadata_routing.MetadataRequest",
"estimator": "sklearn.base.BaseEstimator",
# joblib
"joblib.Parallel": "joblib.Parallel",
# nibabel
"Nifti1Image": "nibabel.nifti1.Nifti1Image",
"Nifti2Image": "nibabel.nifti2.Nifti2Image",
"SpatialImage": "nibabel.spatialimages.SpatialImage",
# MNE
"Label": "mne.Label",
"Forward": "mne.Forward",
"Evoked": "mne.Evoked",
"Info": "mne.Info",
"SourceSpaces": "mne.SourceSpaces",
"Epochs": "mne.Epochs",
"Layout": "mne.channels.Layout",
"EvokedArray": "mne.EvokedArray",
"BiHemiLabel": "mne.BiHemiLabel",
"AverageTFR": "mne.time_frequency.AverageTFR",
"AverageTFRArray": "mne.time_frequency.AverageTFRArray",
"EpochsTFR": "mne.time_frequency.EpochsTFR",
"EpochsTFRArray": "mne.time_frequency.EpochsTFRArray",
"RawTFR": "mne.time_frequency.RawTFR",
"RawTFRArray": "mne.time_frequency.RawTFRArray",
"Raw": "mne.io.Raw",
"ICA": "mne.preprocessing.ICA",
"Covariance": "mne.Covariance",
"Annotations": "mne.Annotations",
"DigMontage": "mne.channels.DigMontage",
"VectorSourceEstimate": "mne.VectorSourceEstimate",
"VolSourceEstimate": "mne.VolSourceEstimate",
"VolVectorSourceEstimate": "mne.VolVectorSourceEstimate",
"MixedSourceEstimate": "mne.MixedSourceEstimate",
"MixedVectorSourceEstimate": "mne.MixedVectorSourceEstimate",
"SourceEstimate": "mne.SourceEstimate",
"Projection": "mne.Projection",
"ConductorModel": "mne.bem.ConductorModel",
"Dipole": "mne.Dipole",
"DipoleFixed": "mne.DipoleFixed",
"InverseOperator": "mne.minimum_norm.InverseOperator",
"CrossSpectralDensity": "mne.time_frequency.CrossSpectralDensity",
"SourceMorph": "mne.SourceMorph",
"Xdawn": "mne.preprocessing.Xdawn",
"Report": "mne.Report",
"TimeDelayingRidge": "mne.decoding.TimeDelayingRidge",
"Vectorizer": "mne.decoding.Vectorizer",
"UnsupervisedSpatialFilter": "mne.decoding.UnsupervisedSpatialFilter",
"TemporalFilter": "mne.decoding.TemporalFilter",
"SSD": "mne.decoding.SSD",
"Scaler": "mne.decoding.Scaler",
"SPoC": "mne.decoding.SPoC",
"PSDEstimator": "mne.decoding.PSDEstimator",
"LinearModel": "mne.decoding.LinearModel",
"FilterEstimator": "mne.decoding.FilterEstimator",
"EMS": "mne.decoding.EMS",
"CSP": "mne.decoding.CSP",
"Beamformer": "mne.beamformer.Beamformer",
"Transform": "mne.transforms.Transform",
"Coregistration": "mne.coreg.Coregistration",
"Figure3D": "mne.viz.Figure3D",
"EOGRegression": "mne.preprocessing.EOGRegression",
"Spectrum": "mne.time_frequency.Spectrum",
"EpochsSpectrum": "mne.time_frequency.EpochsSpectrum",
"EpochsFIF": "mne.Epochs",
"EpochsEEGLAB": "mne.Epochs",
"EpochsKIT": "mne.Epochs",
"RawANT": "mne.io.Raw",
"RawBOXY": "mne.io.Raw",
"RawBrainVision": "mne.io.Raw",
"RawBTi": "mne.io.Raw",
"RawCTF": "mne.io.Raw",
"RawCurry": "mne.io.Raw",
"RawEDF": "mne.io.Raw",
"RawEEGLAB": "mne.io.Raw",
"RawEGI": "mne.io.Raw",
"RawEximia": "mne.io.Raw",
"RawEyelink": "mne.io.Raw",
"RawFIL": "mne.io.Raw",
"RawGDF": "mne.io.Raw",
"RawHitachi": "mne.io.Raw",
"RawKIT": "mne.io.Raw",
"RawNedf": "mne.io.Raw",
"RawNeuralynx": "mne.io.Raw",
"RawNihon": "mne.io.Raw",
"RawNIRX": "mne.io.Raw",
"RawPersyst": "mne.io.Raw",
"RawSNIRF": "mne.io.Raw",
"Calibration": "mne.preprocessing.eyetracking.Calibration",
# dipy
"dipy.align.AffineMap": "dipy.align.imaffine.AffineMap",
"dipy.align.DiffeomorphicMap": "dipy.align.imwarp.DiffeomorphicMap",
}
numpydoc_xref_ignore = {
# words
"and",
"between",
"instance",
"instances",
"of",
"default",
"shape",
"or",
"with",
"length",
"pair",
"matplotlib",
"optional",
"kwargs",
"in",
"dtype",
"object",
# shapes
"n_vertices",
"n_faces",
"n_channels",
"m",
"n",
"n_events",
"n_colors",
"n_times",
"obj",
"n_chan",
"n_epochs",
"n_picks",
"n_ch_groups",
"n_dipoles",
"n_ica_components",
"n_pos",
"n_node_names",
"n_tapers",
"n_signals",
"n_step",
"n_freqs",
"wsize",
"Tx",
"M",
"N",
"p",
"q",
"r",
"n_observations",
"n_regressors",
"n_cols",
"n_frequencies",
"n_tests",
"n_samples",
"n_peaks",
"n_permutations",
"nchan",
"n_points",
"n_features",
"n_parts",
"n_features_new",
"n_components",
"n_labels",
"n_events_in",
"n_splits",
"n_scores",
"n_outputs",
"n_trials",
"n_estimators",
"n_tasks",
"nd_features",
"n_classes",
"n_targets",
"n_slices",
"n_hpi",
"n_fids",
"n_elp",
"n_pts",
"n_tris",
"n_nodes",
"n_nonzero",
"n_events_out",
"n_segments",
"n_orient_inv",
"n_orient_fwd",
"n_orient",
"n_dipoles_lcmv",
"n_dipoles_fwd",
"n_picks_ref",
"n_coords",
"n_meg",
"n_good_meg",
"n_moments",
"n_patterns",
"n_new_events",
# sklearn subclasses
"mapping",
"to",
"any",
"pandas",
"polars",
"default",
# unlinkable
"CoregistrationUI",
"mne_qt_browser.figure.MNEQtBrowser",
# pooch, since its website is unreliable and users will rarely need the links
"pooch.Unzip",
"pooch.Untar",
"pooch.HTTPDownloader",
}
numpydoc_validate = True
numpydoc_validation_checks = {"all"} | set(error_ignores)
numpydoc_validation_exclude = { # set of regex
# dict subclasses
r"\.clear",
r"\.get$",
r"\.copy$",
r"\.fromkeys",
r"\.items",
r"\.keys",
r"\.move_to_end",
r"\.pop",
r"\.popitem",
r"\.setdefault",
r"\.update",
r"\.values",
# list subclasses
r"\.append",
r"\.count",
r"\.extend",
r"\.index",
r"\.insert",
r"\.remove",
r"\.sort",
# we currently don't document these properly (probably okay)
r"\.__getitem__",
r"\.__contains__",
r"\.__hash__",
r"\.__mul__",
r"\.__sub__",
r"\.__add__",
r"\.__iter__",
r"\.__div__",
r"\.__neg__",
# copied from sklearn
r"mne\.utils\.deprecated",
}
# -- Sphinx-gallery configuration --------------------------------------------
examples_dirs = ["../tutorials", "../examples"]
gallery_dirs = ["auto_tutorials", "auto_examples"]
os.environ["_MNE_BUILDING_DOC"] = "true"
scrapers = (
"matplotlib",
"mne_doc_utils.gui_scraper",
"mne_doc_utils.brain_scraper",
"pyvista",
"mne_doc_utils.report_scraper",
"mne_doc_utils.mne_qt_browser_scraper",
)
compress_images = ("images", "thumbnails")
# let's make things easier on Windows users
# (on Linux and macOS it's easy enough to require this)
if sys.platform.startswith("win"):
try:
subprocess.check_call(["optipng", "--version"])
except Exception:
compress_images = ()
sphinx_gallery_parallel = int(os.getenv("MNE_DOC_BUILD_N_JOBS", "1"))
sphinx_gallery_conf = {
"doc_module": ("mne",),
"reference_url": dict(mne=None),
"examples_dirs": examples_dirs,
"subsection_order": ExplicitOrder(
[
"../examples/io/",
"../examples/simulation/",
"../examples/preprocessing/",
"../examples/visualization/",
"../examples/time_frequency/",
"../examples/stats/",
"../examples/decoding/",
"../examples/connectivity/",
"../examples/forward/",
"../examples/inverse/",
"../examples/realtime/",
"../examples/datasets/",
"../tutorials/intro/",
"../tutorials/io/",
"../tutorials/raw/",
"../tutorials/preprocessing/",
"../tutorials/epochs/",
"../tutorials/evoked/",
"../tutorials/time-freq/",
"../tutorials/forward/",
"../tutorials/inverse/",
"../tutorials/stats-sensor-space/",
"../tutorials/stats-source-space/",
"../tutorials/machine-learning/",
"../tutorials/clinical/",
"../tutorials/simulation/",
"../tutorials/sample-datasets/",
"../tutorials/visualization/",
"../tutorials/misc/",
]
),
"gallery_dirs": gallery_dirs,
"default_thumb_file": os.path.join("_static", "mne_helmet.png"),
"backreferences_dir": "generated",
"plot_gallery": "True", # Avoid annoying Unicode/bool default warning
"thumbnail_size": (160, 112),
"remove_config_comments": True,
"min_reported_time": 1.0,
"abort_on_example_error": False,
"reset_modules": (
"matplotlib",
"mne_doc_utils.reset_modules",
), # called w/each script
"reset_modules_order": "both",
"image_scrapers": scrapers,
"show_memory": sys.platform == "linux" and sphinx_gallery_parallel == 1,
"line_numbers": False, # messes with style
"within_subsection_order": "FileNameSortKey",
"capture_repr": ("_repr_html_",),
"junit": os.path.join("..", "test-results", "sphinx-gallery", "junit.xml"),
"matplotlib_animations": True,
"compress_images": compress_images,
"filename_pattern": "^((?!sgskip).)*$",
"exclude_implicit_doc": {
r"mne\.io\.read_raw_fif",
r"mne\.io\.Raw",
r"mne\.Epochs",
r"mne.datasets.*",
},
"show_api_usage": "unused",
"api_usage_ignore": (
"("
".*__.*__|" # built-ins
".*Base.*|.*Array.*|mne.Vector.*|mne.Mixed.*|mne.Vol.*|" # inherited
"mne.coreg.Coregistration.*|" # GUI
# common
".*utils.*|.*verbose()|.*copy()|.*update()|.*save()|"
".*get_data()|"
# mixins
".*add_channels()|.*add_reference_channels()|"
".*anonymize()|.*apply_baseline()|.*apply_function()|"
".*apply_hilbert()|.*as_type()|.*decimate()|"
".*drop()|.*drop_channels()|.*drop_log_stats()|"
".*export()|.*get_channel_types()|"
".*get_montage()|.*interpolate_bads()|.*next()|"
".*pick()|.*pick_channels()|.*pick_types()|"
".*plot_sensors()|.*rename_channels()|"
".*reorder_channels()|.*savgol_filter()|"
".*set_eeg_reference()|.*set_channel_types()|"
".*set_meas_date()|.*set_montage()|.*shift_time()|"
".*time_as_index()|.*to_data_frame()|"
# dictionary inherited
".*clear()|.*fromkeys()|.*get()|.*items()|"
".*keys()|.*pop()|.*popitem()|.*setdefault()|"
".*values()|"
# sklearn inherited
".*apply()|.*decision_function()|.*fit()|"
".*fit_transform()|.*get_params()|.*predict()|"
".*predict_proba()|.*set_params()|.*transform()|"
# I/O, also related to mixins
".*.remove.*|.*.write.*)"
),
"copyfile_regex": r".*index\.rst", # allow custom index.rst files
"parallel": sphinx_gallery_parallel,
}
assert is_serializable(sphinx_gallery_conf)
# Files were renamed from plot_* with:
# find . -type f -name 'plot_*.py' -exec sh -c 'x="{}"; xn=`basename "${x}"`; git mv "$x" `dirname "${x}"`/${xn:5}' \; # noqa
def append_attr_meth_examples(app, what, name, obj, options, lines):
"""Append SG examples backreferences to method and attr docstrings."""
# NumpyDoc nicely embeds method and attribute docstrings for us, but it
# does not respect the autodoc templates that would otherwise insert
# the .. include:: lines, so we need to do it.
# Eventually this could perhaps live in SG.
if what in ("attribute", "method"):
size = os.path.getsize(
os.path.join(
os.path.dirname(__file__),
"generated",
f"{name}.examples",
)
)
if size > 0:
lines += """
.. _sphx_glr_backreferences_{1}:
.. rubric:: Examples using ``{0}``:
.. minigallery:: {1}
""".format(name.split(".")[-1], name).split("\n")
def fix_sklearn_inherited_docstrings(app, what, name, obj, options, lines):
"""Fix sklearn docstrings because they use autolink and we do not."""
if (
name.startswith("mne.decoding.") or name.startswith("mne.preprocessing.Xdawn")
) and name.endswith(
(
".get_metadata_routing",
".fit",
".fit_transform",
".set_output",
".transform",
)
):
if ":Parameters:" in lines:
loc = lines.index(":Parameters:")
else:
loc = lines.index(":Returns:")
lines.insert(loc, "")
lines.insert(loc, ".. default-role:: autolink")
lines.insert(loc, "")
# -- Other extension configuration -------------------------------------------
# Consider using http://magjac.com/graphviz-visual-editor for this
graphviz_dot_args = [
"-Gsep=-0.5",
"-Gpad=0.5",
"-Nshape=box",
"-Nfontsize=20",
"-Nfontname=Open Sans,Arial",
]
graphviz_output_format = "svg" # for API usage diagrams
user_agent = "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Mobile Safari/537.36" # noqa: E501
# Can eventually add linkcheck_request_headers if needed
linkcheck_ignore = [ # will be compiled to regex
# 403 Client Error: Forbidden
"https://doi.org/10.1002/", # onlinelibrary.wiley.com/doi/10.1002/hbm
"https://doi.org/10.1016/", # neuroimage
"https://doi.org/10.1021/", # pubs.acs.org/doi/abs
"https://doi.org/10.1073/", # pnas.org
"https://doi.org/10.1093/", # academic.oup.com/sleep/
"https://doi.org/10.1098/", # royalsocietypublishing.org
"https://doi.org/10.1101/", # www.biorxiv.org
"https://doi.org/10.1103", # journals.aps.org/rmp
"https://doi.org/10.1111/", # onlinelibrary.wiley.com/doi/10.1111/psyp
"https://doi.org/10.1126/", # www.science.org
"https://doi.org/10.1137/", # epubs.siam.org
"https://doi.org/10.1155/", # www.hindawi.com/journals/cin
"https://doi.org/10.1161/", # www.ahajournals.org
"https://doi.org/10.1162/", # direct.mit.edu/neco/article/
"https://doi.org/10.1167/", # jov.arvojournals.org
"https://doi.org/10.1177/", # journals.sagepub.com
"https://doi.org/10.1063/", # pubs.aip.org/aip/jap
"https://doi.org/10.1080/", # www.tandfonline.com
"https://doi.org/10.1088/", # www.tandfonline.com
"https://doi.org/10.3109/", # www.tandfonline.com
"https://www.researchgate.net/profile/",
"https://www.intel.com/content/www/us/en/developer/tools/oneapi/onemkl.html",
r"https://scholar.google.com/scholar\?cites=12188330066413208874&as_ylo=2014",
r"https://scholar.google.com/scholar\?cites=1521584321377182930&as_ylo=2013",
"https://www.research.chop.edu/imaging",
"http://prdownloads.sourceforge.net/optipng",
"https://sourceforge.net/projects/aespa/files/",
"https://sourceforge.net/projects/ezwinports/files/",
"https://www.mathworks.com/products/compiler/matlab-runtime.html",
"https://medicine.umich.edu/dept/khri/ross-maddox-phd",
# 500 server error
"https://openwetware.org/wiki/Beauchamp:FreeSurfer",
# 503 Server error
"https://hal.archives-ouvertes.fr/hal-01848442",
# Read timed out
"http://www.cs.ucl.ac.uk/staff/d.barber/brml",
"https://www.cea.fr",
"http://www.humanconnectome.org/data",
"https://www.mail-archive.com/freesurfer@nmr.mgh.harvard.edu",
# Max retries exceeded
"https://doi.org/10.7488/ds/1556",
"https://datashare.is.ed.ac.uk/handle/10283",
"https://imaging.mrc-cbu.cam.ac.uk/imaging/MniTalairach",
"https://www.nyu.edu/",
# Too slow
"https://speakerdeck.com/dengemann/",
"https://www.dtu.dk/english/service/phonebook/person",
"https://www.gnu.org/software/make/",
"https://www.macports.org/",
"https://hastie.su.domains/CASI",
# SSL problems sometimes
"http://ilabs.washington.edu",
"https://psychophysiology.cpmc.columbia.edu",
"https://erc.easme-web.eu",
# Not rendered by linkcheck builder
r"ides\.html",
]
linkcheck_anchors = False # saves a bit of time
linkcheck_timeout = 15 # some can be quite slow
linkcheck_retries = 3
linkcheck_report_timeouts_as_broken = False
# autodoc / autosummary
autosummary_generate = True
autodoc_default_options = {"inherited-members": None}
# sphinxcontrib-bibtex
bibtex_bibfiles = ["./references.bib"]
bibtex_style = "unsrt"
bibtex_footbibliography_header = ""
# -- Nitpicky ----------------------------------------------------------------
nitpicky = True
show_warning_types = True
nitpick_ignore = [
("py:class", "None. Remove all items from D."),
("py:class", "a set-like object providing a view on D's items"),
("py:class", "a set-like object providing a view on D's keys"),
(
"py:class",
"v, remove specified key and return the corresponding value.",
), # noqa: E501
("py:class", "None. Update D from dict/iterable E and F."),
("py:class", "an object providing a view on D's values"),
("py:class", "a shallow copy of D"),
("py:class", "(k, v), remove and return some (key, value) pair as a"),
("py:class", "_FuncT"), # type hint used in @verbose decorator
("py:class", "mne.utils._logging._FuncT"),
("py:class", "None. Remove all items from od."),
]
nitpick_ignore_regex = [
# Classes whose methods we purposefully do not document
("py:.*", r"mne\.io\.BaseRaw.*"), # use mne.io.Raw
("py:.*", r"mne\.BaseEpochs.*"), # use mne.Epochs
# Type hints for undocumented types
("py:.*", r"mne\.io\..*\.Raw.*"), # RawEDF etc.
("py:.*", r"mne\.epochs\.EpochsFIF.*"),
("py:.*", r"mne\.io\..*\.Epochs.*"), # EpochsKIT etc.
( # BaseRaw attributes are documented in Raw
"py:obj",
"(filename|metadata|proj|times|tmax|tmin|annotations|ch_names"
"|compensation_grade|duration|filenames|first_samp|first_time"
"|last_samp|n_times|proj|times|tmax|tmin)",
),
]
suppress_warnings = [
"image.nonlocal_uri", # we intentionally link outside
]
# -- Sphinx hacks / overrides ------------------------------------------------
versionlabels["versionadded"] = sphinx.locale._("New in v%s")
# -- 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 = "pydata_sphinx_theme"
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
switcher_version_match = "dev" if ".dev" in version else version
html_theme_options = {
"icon_links": [
dict(
name="Discord",
url="https://discord.gg/rKfvxTuATa",
icon="fa-brands fa-discord fa-fw",
),
dict(
name="Mastodon",
url="https://fosstodon.org/@mne",
icon="fa-brands fa-mastodon fa-fw",
attributes=dict(rel="me"),
),
dict(
name="Forum",
url="https://mne.discourse.group/",
icon="fa-brands fa-discourse fa-fw",
),
dict(
name="GitHub",
url="https://github.com/mne-tools/mne-python",
icon="fa-brands fa-square-github fa-fw",
),
],
"icon_links_label": "External Links", # for screen reader
"use_edit_page_button": False,
"navigation_with_keys": False,
"show_toc_level": 1,
"article_header_start": [], # disable breadcrumbs
"navbar_end": [
"theme-switcher",
"version-switcher",
"navbar-icon-links",
],
"navbar_align": "left",
"navbar_persistent": ["search-button"],
"footer_start": ["copyright"],
"secondary_sidebar_items": ["page-toc", "edit-this-page"],
"analytics": dict(google_analytics_id="G-5TBCPCRB6X"),
"switcher": {
"json_url": "https://mne.tools/dev/_static/versions.json",
"version_match": switcher_version_match,
},
"back_to_top_button": False,
}
# The name of an image file (relative to this directory) to place at the top
# of the sidebar.
html_logo = "_static/mne_logo_small.svg"
# The name of an image file (within the static path) to use as 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 = [
"style.css",
]
# Add any extra paths that contain custom files (such as robots.txt or
# .htaccess) here, relative to this directory. These files are copied
# directly to the root of the documentation.
html_extra_path = [
"contributing.html",
"documentation.html",
"getting_started.html",
"install_mne_python.html",
]
# Custom sidebar templates, maps document names to template names.
html_sidebars = {
"index": ["sidebar-quicklinks.html"],
}
# If true, links to the reST sources are added to the pages.
html_show_sourcelink = False
html_copy_source = False
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
html_show_sphinx = False
# accommodate different logo shapes (width values in rem)
xs = "2"
sm = "2.5"
md = "3"
lg = "4.5"
xl = "5"
xxl = "6"
# variables to pass to HTML templating engine
html_context = {
"default_mode": "auto",
# next 3 are for the "edit this page" button
"github_user": "mne-tools",
"github_repo": "mne-python",
"github_version": "main",
"doc_path": "doc",
"funders": [
dict(img="nih.svg", size="3", title="National Institutes of Health"),
dict(img="nsf.png", size="3.5", title="US National Science Foundation"),
dict(
img="erc.svg",
size="3.5",
title="European Research Council",
klass="only-light",
),
dict(
img="erc-dark.svg",
size="3.5",
title="European Research Council",
klass="only-dark",
),
dict(img="doe.svg", size="3", title="US Department of Energy"),
dict(img="anr.svg", size="3.5", title="Agence Nationale de la Recherche"),
dict(
img="cds.svg",
size="1.75",
title="Paris-Saclay Center for Data Science",
klass="only-light",
),
dict(
img="cds-dark.svg",
size="1.75",
title="Paris-Saclay Center for Data Science",
klass="only-dark",
),
dict(img="google.svg", size="2.25", title="Google"),
dict(img="amazon.svg", size="2.5", title="Amazon"),
dict(img="czi.svg", size="2.5", title="Chan Zuckerberg Initiative"),
],
"institutions": [
dict(
name="Massachusetts General Hospital",
img="MGH.svg",
url="https://www.massgeneral.org/",
size=sm,
),
dict(
name="Athinoula A. Martinos Center for Biomedical Imaging",
img="Martinos.png",
url="https://martinos.org/",
size=md,
),
dict(
name="Harvard Medical School",
img="Harvard.png",
url="https://hms.harvard.edu/",
size=sm,
),
dict(
name="Massachusetts Institute of Technology",
img="MIT.svg",
url="https://web.mit.edu/",
size=md,
),
dict(
name="New York University",
img="NYU.svg",
url="https://www.nyu.edu/",
size=xs,
klass="only-light",
),
dict(
name="New York University",
img="NYU-dark.svg",
url="https://www.nyu.edu/",
size=xs,
klass="only-dark",
),
dict(
name="Commissariat à l´énergie atomique et aux énergies alternatives", # noqa E501
img="CEA.png",
url="http://www.cea.fr/",
size=md,
),
dict(
name="Aalto-yliopiston perustieteiden korkeakoulu",
img="Aalto.svg",
url="https://sci.aalto.fi/",
size=md,
klass="only-light",
),
dict(
name="Aalto-yliopiston perustieteiden korkeakoulu",
img="Aalto-dark.svg",
url="https://sci.aalto.fi/",
size=md,
klass="only-dark",
),
dict(
name="Télécom ParisTech",
img="Telecom_Paris_Tech.svg",
url="https://www.telecom-paris.fr/",
size=md,
),
dict(
name="University of Washington",
img="Washington.svg",
url="https://www.washington.edu/",
size=md,
klass="only-light",
),
dict(
name="University of Washington",
img="Washington-dark.svg",
url="https://www.washington.edu/",
size=md,
klass="only-dark",
),
dict(
name="Institut du Cerveau et de la Moelle épinière",
img="ICM.jpg",
url="https://icm-institute.org/",
size=md,
),
dict(
name="Boston University", img="BU.svg", url="https://www.bu.edu/", size=lg
),
dict(
name="Institut national de la santé et de la recherche médicale",
img="Inserm.svg",
url="https://www.inserm.fr/",
size=xl,
klass="only-light",