|
78 | 78 | # -- General configuration ---------------------------------------------------
|
79 | 79 | # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
|
80 | 80 |
|
81 |
| -# pylint: disable=invalid-name |
82 |
| -# Fixes ISSUE #561 pending a fix for ISSUE #570 |
83 |
| -show_warning_types = True |
84 |
| -suppress_warnings = ["config.cache"] |
85 |
| -# pylint: enable=invalid-name |
86 | 81 |
|
87 | 82 | # sphinx extensions
|
88 | 83 | extensions = [
|
|
216 | 211 | ("py:class", r"jaxtyping\.Shaped\[Array, '.*']"),
|
217 | 212 | ]
|
218 | 213 |
|
219 |
| -autodoc_custom_types: dict[Any, str] = { # Specify custom types for autodoc_type_hints |
220 |
| - ArrayLike: ":data:`~jax.typing.ArrayLike`", |
221 |
| -} |
222 |
| - |
223 | 214 | # custom references for tqdm, which does not support intersphinx
|
224 | 215 | tqdm_refs: dict[str, dict[str, str]] = {
|
225 | 216 | "py:class": {
|
226 | 217 | "tqdm.tqdm": "tqdm/#tqdm-objects",
|
227 | 218 | }
|
228 | 219 | }
|
229 | 220 |
|
230 |
| - |
231 |
| -def typehints_formatter( |
232 |
| - annotation: Any, config: sphinx.config.Config |
233 |
| -) -> Union[str, None]: |
234 |
| - """ |
235 |
| - Properly replace custom type aliases. |
236 |
| -
|
237 |
| - :param annotation: The type annotation to be processed. |
238 |
| - :param config: The current configuration being used. |
239 |
| - :returns: A string of reStructured text (e.g. :py:class:`something`) or None to fall |
240 |
| - back to the default. |
241 |
| -
|
242 |
| - This function is called on each type annotation that Sphinx processes. |
243 |
| - The following steps occur: |
244 |
| -
|
245 |
| - 1. Check if the annotation is a TypeVar. If so, replace it with its "bound" type |
246 |
| - for clarity in the docs. If not, then replace it with typing.Any. |
247 |
| - 2. Check whether a specific Sphinx string has been defined in autodoc_custom_types. |
248 |
| - If so, return that. |
249 |
| - 3. If not, then return None, which uses thee default formatter. |
250 |
| -
|
251 |
| - See https://github.com/tox-dev/sphinx-autodoc-typehints?tab=readme-ov-file#options |
252 |
| - for specification. |
253 |
| - """ |
254 |
| - if isinstance(annotation, TypeVar): |
255 |
| - if annotation.__bound__ is None: # when a generic TypeVar has been used. |
256 |
| - return default_format_annotation(Any, config) |
257 |
| - return default_format_annotation( |
258 |
| - annotation.__bound__, config |
259 |
| - ) # get the annotation for the bound type |
260 |
| - return autodoc_custom_types.get(annotation) |
261 |
| - |
262 |
| - |
263 | 221 | # -- Options for HTML output -------------------------------------------------
|
264 | 222 | # https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
|
265 | 223 |
|
|
0 commit comments