Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions doc/sphinxext/gh_substitutions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,24 @@
# License: BSD-3-Clause
# Copyright the MNE-Python contributors.

import docutils
from docutils.nodes import reference
from docutils.parsers.rst.roles import set_classes

# Adapted from sphinx
if docutils.__version_info__[:2] < (0, 22):
from docutils.parsers.rst import roles

def _normalize_options(options):
if options is None:
return {}
n_options = options.copy()
roles.set_classes(n_options)
return n_options

else:
from docutils.parsers.rst.roles import (
normalize_options as _normalize_options,
)


def gh_role(name, rawtext, text, lineno, inliner, options={}, content=[]): # noqa: B006
Expand All @@ -22,7 +38,7 @@ def gh_role(name, rawtext, text, lineno, inliner, options={}, content=[]): # no
slug = "issues/" + text
text = "#" + text
ref = "https://github.com/mne-tools/mne-python/" + slug
set_classes(options)
options = _normalize_options(options)
node = reference(rawtext, text, refuri=ref, **options)
return [node], []

Expand Down
10 changes: 10 additions & 0 deletions doc/sphinxext/mne_doc_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,16 @@ def reset_warnings(gallery_conf, fname):
warnings.filterwarnings( # deal with other modules having bad imports
"ignore", message=f".*{key}.*", category=DeprecationWarning
)
# ignore (PendingDeprecationWarning)
for key in (
# sphinx
"The mapping interface for autodoc options",
# sphinxcontrib-bibtex
"sphinx.environment.BuildEnvironment.app' is deprecated",
):
warnings.filterwarnings( # deal with other modules having bad imports
"ignore", message=f".*{key}.*", category=PendingDeprecationWarning
)
# ignore (UserWarning)
for message in (
# Matplotlib
Expand Down