Skip to content

Commit 77320a5

Browse files
authored
Bump sphinx to 3.0 (#240)
`m2r` is currently broken upstream, so we have to monkey-patch sphinx in order to keep it working. `autodoc_default_flags` was deprecated and has been replaced with `autodoc_default_options`. This also adds the markdown docs we don't care about to `exclude_patterns`, rather than wasting time building them
1 parent 46cde16 commit 77320a5

File tree

2 files changed

+36
-11
lines changed

2 files changed

+36
-11
lines changed

doc/conf.py

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
# -- Imports
2020

2121
import sphinx_rtd_theme
22+
import sphinx
2223

2324
# -- Project information -----------------------------------------------------
2425

@@ -51,6 +52,24 @@
5152
'releases'
5253
]
5354

55+
56+
def monkeypatch(cls):
57+
""" decorator to monkey-patch methods """
58+
def decorator(f):
59+
method = f.__name__
60+
old_method = getattr(cls, method)
61+
setattr(cls, method, lambda self, *args, **kwargs: f(old_method, self, *args, **kwargs))
62+
return decorator
63+
64+
# workaround until https://github.com/miyakogi/m2r/pull/55 is merged
65+
@monkeypatch(sphinx.registry.SphinxComponentRegistry)
66+
def add_source_parser(_old_add_source_parser, self, *args, **kwargs):
67+
# signature is (parser: Type[Parser], **kwargs), but m2r expects
68+
# the removed (str, parser: Type[Parser], **kwargs).
69+
if isinstance(args[0], str):
70+
args = args[1:]
71+
return _old_add_source_parser(self, *args, **kwargs)
72+
5473
# -- nbsphinx configuration ---------------------------------------------------
5574

5675
import galgebra
@@ -66,15 +85,15 @@
6685
napoleon_include_init_with_doc= False
6786

6887
autoclass_content = "both" # include both class docstring and __init__
69-
autodoc_default_flags = [
88+
autodoc_default_options = {
7089
# Make sure that any autodoc declarations show the right members
71-
"members",
72-
"inherited-members",
73-
# "undoc-members",
74-
# "special-members",
75-
# "private-members",
76-
# "show-inheritance",
77-
]
90+
"members": True,
91+
"inherited-members": True,
92+
# "undoc-members": True,
93+
# "special-members": True,
94+
# "private-members": True,
95+
# "show-inheritance": True,
96+
}
7897

7998
#autodoc_default_flags='members'
8099
# you have to list all files with automodule here due to bug in sphinx and nbsphinx
@@ -95,7 +114,7 @@
95114
# You can specify multiple suffix as a list of string:
96115
#
97116
# source_suffix = ['.rst', '.md']
98-
source_suffix = ['.rst', '.md']
117+
source_suffix = ['.rst']
99118

100119
# The master toctree document.
101120
master_doc = 'index'
@@ -110,7 +129,13 @@
110129
# List of patterns, relative to source directory, that match files and
111130
# directories to ignore when looking for source files.
112131
# This pattern also affects html_static_path and html_extra_path.
113-
exclude_patterns = ['_build', '**.ipynb_checkpoints', 'Thumbs.db', '.DS_Store']
132+
exclude_patterns = [
133+
'_build', '**.ipynb_checkpoints', 'Thumbs.db', '.DS_Store',
134+
# these are here for users, not for Sphinx
135+
'books', 'old_installation.md', 'old_introduction.md',
136+
# this is converted into ipynb elsewhere
137+
'galgebra.md',
138+
]
114139

115140
# The name of the Pygments (syntax highlighting) style to use.
116141
pygments_style = 'sphinx'

doc/readthedocs-pip-requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ numpy
33
ipython
44
matplotlib
55
scipy
6-
sphinx>=1.4
6+
sphinx~=3.0
77
ipykernel
88
nbsphinx
99
numba

0 commit comments

Comments
 (0)