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
22 changes: 18 additions & 4 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# https://www.sphinx-doc.org/en/master/usage/configuration.html

import contextlib
import functools
import logging
import os.path
import shutil
Expand Down Expand Up @@ -119,7 +118,7 @@ def skip(*args) -> bool:
name = args[2]
would_skip = args[4]

if name == "__weakref__":
if name in ("__weakref__", "__subclasshook__"):
return True
return would_skip

Expand Down Expand Up @@ -154,7 +153,10 @@ def setup(app: Sphinx) -> None:

ignored_targets = [
"async_rediscache",
"pydantic.main.BaseModel"
"pydantic.main.BaseModel",
"pydantic_core.*",
"pydantic._internal.*",
"pydantic.plugin.*"
]

# nitpick raises warnings as errors. This regex tells nitpick to ignore any warnings that match this regex.
Expand All @@ -163,6 +165,11 @@ def setup(app: Sphinx) -> None:
("py:.*", "|".join([f".*{entry}.*" for entry in ignored_targets])),
]

suppress_warnings = [
"sphinx_autodoc_typehints.forward_reference",
"sphinx_autodoc_typehints.guarded_import",
]

# -- Extension configuration -------------------------------------------------

# -- Options for todo extension ----------------------------------------------
Expand Down Expand Up @@ -190,11 +197,18 @@ def setup(app: Sphinx) -> None:
"aiohttp": ("https://docs.aiohttp.org/en/stable/", None),
"statsd": ("https://statsd.readthedocs.io/en/v3.3/", ("_static/statsd_additional_objects.inv", None)),
"pydantic": ("https://docs.pydantic.dev/latest/", None),
"dateutil": ("https://dateutil.readthedocs.io/en/stable/", None),
}


# -- Options for the linkcode extension --------------------------------------
linkcode_resolve = functools.partial(utils.linkcode_resolve, REPO_LINK)
def _safe_linkcode_resolve(domain: str, info: dict[str, str]) -> str | None:
try:
return utils.linkcode_resolve(REPO_LINK, domain, info)
except ValueError:
return None

linkcode_resolve = _safe_linkcode_resolve


# -- Options for releases extension ------------------------------------------
Expand Down
6 changes: 5 additions & 1 deletion docs/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,11 @@ def linkcode_resolve(repo_link: str, domain: str, info: dict[str, str]) -> str |
# in multiversion builds. We load the module from the file location instead
spec = importlib.util.spec_from_file_location(info["module"], origin, submodule_search_locations=search_locations)
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)

try:
spec.loader.exec_module(module)
except Exception: # noqa: BLE001
return None

symbol = [module]
for name in symbol_name.split("."):
Expand Down
Loading
Loading