|
13 | 13 | import os |
14 | 14 | import sys |
15 | 15 |
|
16 | | -import sphinx |
17 | | - |
18 | 16 | sys.path.insert(0, os.path.abspath('..')) |
19 | 17 |
|
20 | 18 |
|
21 | | -# -- Monkeypatches ----------------------------------------------------------- |
22 | | - |
23 | | -def _monkeypatch(cls): |
24 | | - """Decorator to monkey-patch methods.""" |
25 | | - def decorator(func): |
26 | | - method = func.__name__ |
27 | | - old = getattr(cls, method) |
28 | | - setattr( |
29 | | - cls, |
30 | | - method, |
31 | | - lambda inst, *args, **kwargs: func(inst, old, *args, **kwargs), |
32 | | - ) |
33 | | - return decorator |
34 | | - |
35 | | - |
36 | | -# workaround until https://github.com/miyakogi/m2r/pull/55 is merged |
37 | | -@_monkeypatch(sphinx.registry.SphinxComponentRegistry) |
38 | | -def add_source_parser(self, _old_add_source_parser, *args, **kwargs): |
39 | | - """This function changed in sphinx v3.0, we need to fix it back.""" |
40 | | - # signature is (parser: "Type[Parser]", override: bool = False), |
41 | | - # but m2r expects the removed (str, parser: Type[Parser], **kwargs). |
42 | | - if not isinstance(args[0], str): |
43 | | - return _old_add_source_parser(self, *args, **kwargs) |
44 | | - |
45 | | - |
46 | 19 | # -- Project information ----------------------------------------------------- |
47 | 20 |
|
48 | 21 | def _get_project_meta(): |
@@ -80,7 +53,7 @@ def _get_project_meta(): |
80 | 53 | 'sphinx.ext.napoleon', |
81 | 54 |
|
82 | 55 | # Used to include .md files: |
83 | | - 'm2r', |
| 56 | + 'm2r2', |
84 | 57 |
|
85 | 58 | # Used to insert typehints into the final docs: |
86 | 59 | 'sphinx_autodoc_typehints', |
|
0 commit comments