diff --git a/docs/conf.py b/docs/conf.py index 8a8501d1..449ac3d9 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -2,6 +2,13 @@ from datetime import date, datetime +from docutils.nodes import Element, Text +from sphinx.addnodes import pending_xref +from sphinx.application import Sphinx +from sphinx.builders import Builder +from sphinx.domains.python import PythonDomain +from sphinx.environment import BuildEnvironment + from filelock import __version__ name, company = "filelock", "tox-dev" @@ -30,3 +37,25 @@ "pr": ("https://github.com/tox-dev/py-filelock/issues/%s", "PR #%s"), "user": ("https://github.com/%s", "@%s"), } + + +def setup(app: Sphinx) -> None: + class PatchedPythonDomain(PythonDomain): + def resolve_xref( + self, + env: BuildEnvironment, + fromdocname: str, + builder: Builder, + type: str, + target: str, + node: pending_xref, + contnode: Element, + ) -> Element: + mapping = {"_thread._local": ("threading.local", "local")} + if target in mapping: + of_type, with_name = mapping[target] + target = node["reftarget"] = of_type + contnode.children[0] = Text(with_name, with_name) + return super().resolve_xref(env, fromdocname, builder, type, target, node, contnode) + + app.add_domain(PatchedPythonDomain, override=True) diff --git a/tox.ini b/tox.ini index 0d21a506..b71c95c6 100644 --- a/tox.ini +++ b/tox.ini @@ -21,7 +21,7 @@ wheel_build_env = .pkg extras = testing passenv = - PYTEST_* + PYTEST_ADDOPTS setenv = COVERAGE_FILE = {toxworkdir}{/}.coverage.{envname} commands = @@ -38,8 +38,6 @@ basepython = python3.10 skip_install = true deps = pre-commit>=3.2.1 -passenv = - * commands = pre-commit run --all-files --show-diff-on-failure python -c 'import pathlib; print("hint: run \{\} install to add checks as pre-commit hook".format(pathlib.Path(r"{envdir}") / "bin" / "pre-commit"))' @@ -85,7 +83,7 @@ description = build documentation extras = docs commands = - sphinx-build -d "{envtmpdir}{/}doctree" docs "{toxworkdir}{/}docs_out" --color -b html {posargs} + sphinx-build -d "{envtmpdir}{/}doctree" docs "{toxworkdir}{/}docs_out" --color -b html -W {posargs} python -c 'print(r"documentation available under file://{toxworkdir}{/}docs_out{/}index.html")' [testenv:readme] diff --git a/whitelist.txt b/whitelist.txt index 90d6069e..54a6c420 100644 --- a/whitelist.txt +++ b/whitelist.txt @@ -1,13 +1,17 @@ +addnodes autoclass autodoc autosectionlabel caplog +contnode +docutils eacces enosys extlinks fchmod filelock filemode +fromdocname fspath getframeinfo intersphinx