|
1 | | -# Configuration file for the Sphinx documentation builder. |
| 1 | +# Base configuration file for the Sphinx documentation builder. |
2 | 2 | # |
3 | 3 | # This file only contains a selection of the most common options. For a full |
4 | 4 | # list see the documentation: |
5 | 5 | # https://www.sphinx-doc.org/en/master/usage/configuration.html |
| 6 | +import re |
6 | 7 |
|
7 | | -# -- Path setup -------------------------------------------------------------- |
8 | | - |
9 | | -# If extensions (or modules to document with autodoc) are in another directory, |
10 | | -# add these directories to sys.path here. If the directory is relative to the |
11 | | -# documentation root, use os.path.abspath to make it absolute, like shown here. |
12 | | -# |
13 | | -import os |
14 | | -import sys |
15 | 8 | import sphinx_material |
16 | | -import array_api_stubs |
17 | 9 |
|
18 | 10 | # -- Project information ----------------------------------------------------- |
19 | 11 |
|
20 | 12 | project = 'Python array API standard' |
21 | 13 | copyright = '2020, Consortium for Python Data API Standards' |
22 | 14 | author = 'Consortium for Python Data API Standards' |
23 | 15 |
|
24 | | -# The full version, including alpha/beta/rc tags |
25 | | -release = '2022.05-DRAFT' |
26 | | - |
27 | | - |
28 | 16 | # -- General configuration --------------------------------------------------- |
29 | 17 |
|
30 | 18 | # Add any Sphinx extension module names here, as strings. They can be |
|
64 | 52 | # autodoc wants to make cross-references for every type hint. But a lot of |
65 | 53 | # them don't actually refer to anything that we have a document for. |
66 | 54 | nitpick_ignore = [ |
67 | | - ('py:class', 'device'), |
68 | | - ('py:class', 'dtype'), |
69 | | - ('py:class', 'NestedSequence'), |
70 | | - ('py:class', 'SupportsBufferProtocol'), |
71 | 55 | ('py:class', 'collections.abc.Sequence'), |
72 | 56 | ('py:class', "Optional[Union[int, float, Literal[inf, - inf, 'fro', 'nuc']]]"), |
73 | 57 | ('py:class', "Union[int, float, Literal[inf, - inf]]"), |
74 | 58 | ('py:obj', "typing.Optional[typing.Union[int, float, typing.Literal[inf, - inf, 'fro', 'nuc']]]"), |
75 | 59 | ('py:obj', "typing.Union[int, float, typing.Literal[inf, - inf]]"), |
76 | | - ('py:class', 'PyCapsule'), |
77 | 60 | ('py:class', 'enum.Enum'), |
78 | 61 | ('py:class', 'ellipsis'), |
79 | | - ('py:class', 'finfo_object'), |
80 | | - ('py:class', 'iinfo_object'), |
81 | 62 | ] |
82 | 63 | nitpick_ignore_regex = [ |
83 | 64 | ('py:class', '.*array'), |
| 65 | + ('py:class', '.*device'), |
| 66 | + ('py:class', '.*dtype'), |
| 67 | + ('py:class', '.*NestedSequence'), |
| 68 | + ('py:class', '.*SupportsBufferProtocol'), |
| 69 | + ('py:class', '.*PyCapsule'), |
| 70 | + ('py:class', '.*finfo_object'), |
| 71 | + ('py:class', '.*iinfo_object'), |
84 | 72 | ] |
85 | 73 | # In array_object.py we have to use aliased names for some types because they |
86 | 74 | # would otherwise refer back to method objects of array |
|
101 | 89 | autosummary_mod.mangle_signature = lambda sig, max_chars=30: sig |
102 | 90 |
|
103 | 91 | # Add any paths that contain templates here, relative to this directory. |
104 | | -templates_path = ['_templates'] |
| 92 | +templates_path = ['../_templates'] |
105 | 93 |
|
106 | 94 | # List of patterns, relative to source directory, that match files and |
107 | 95 | # directories to ignore when looking for source files. |
|
125 | 113 | # Add any paths that contain custom static files (such as style sheets) here, |
126 | 114 | # relative to this directory. They are copied after the builtin static files, |
127 | 115 | # so a file named "default.css" will overwrite the builtin "default.css". |
128 | | -html_static_path = ['_static'] |
| 116 | +html_static_path = ['../_static'] |
129 | 117 |
|
130 | 118 |
|
131 | 119 | # -- Material theme options (see theme.conf for more information) ------------ |
|
137 | 125 | html_theme_options = { |
138 | 126 |
|
139 | 127 | # Set the name of the project to appear in the navigation. |
140 | | - 'nav_title': f'Python array API standard {release}', |
| 128 | + 'nav_title': f'Python array API standard', |
141 | 129 |
|
142 | 130 | # Set you GA account ID to enable tracking |
143 | 131 | #'google_analytics_account': 'UA-XXXXX', |
|
206 | 194 | "pypa": ("https://packaging.python.org/%s", ""), |
207 | 195 | } |
208 | 196 |
|
| 197 | +# -- Prettify type hints ----------------------------------------------------- |
| 198 | +r_type_prefix = re.compile(r"array_api_stubs\._[a-z0-9_]+\._types\.") |
209 | 199 |
|
210 | 200 | def process_signature(app, what, name, obj, options, signature, return_annotation): |
211 | 201 | if signature: |
212 | | - signature = signature.replace("array_api._types.", "") |
| 202 | + signature = re.sub(r_type_prefix, "", signature) |
213 | 203 | if return_annotation: |
214 | | - return_annotation = return_annotation.replace("array_api._types.", "") |
| 204 | + return_annotation = re.sub(r_type_prefix, "", return_annotation) |
215 | 205 | return signature, return_annotation |
216 | 206 |
|
217 | 207 | def setup(app): |
|
0 commit comments