Skip to content

Commit d44bd10

Browse files
Fix: #225 :Get rid of warning about inability to link to _thread._local. (#226)
Co-authored-by: Bernát Gábor <[email protected]>
1 parent d3241b9 commit d44bd10

File tree

3 files changed

+35
-4
lines changed

3 files changed

+35
-4
lines changed

docs/conf.py

+29
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
from datetime import date, datetime
44

5+
from docutils.nodes import Element, Text
6+
from sphinx.addnodes import pending_xref
7+
from sphinx.application import Sphinx
8+
from sphinx.builders import Builder
9+
from sphinx.domains.python import PythonDomain
10+
from sphinx.environment import BuildEnvironment
11+
512
from filelock import __version__
613

714
name, company = "filelock", "tox-dev"
@@ -30,3 +37,25 @@
3037
"pr": ("https://github.com/tox-dev/py-filelock/issues/%s", "PR #%s"),
3138
"user": ("https://github.com/%s", "@%s"),
3239
}
40+
41+
42+
def setup(app: Sphinx) -> None:
43+
class PatchedPythonDomain(PythonDomain):
44+
def resolve_xref(
45+
self,
46+
env: BuildEnvironment,
47+
fromdocname: str,
48+
builder: Builder,
49+
type: str,
50+
target: str,
51+
node: pending_xref,
52+
contnode: Element,
53+
) -> Element:
54+
mapping = {"_thread._local": ("threading.local", "local")}
55+
if target in mapping:
56+
of_type, with_name = mapping[target]
57+
target = node["reftarget"] = of_type
58+
contnode.children[0] = Text(with_name, with_name)
59+
return super().resolve_xref(env, fromdocname, builder, type, target, node, contnode)
60+
61+
app.add_domain(PatchedPythonDomain, override=True)

tox.ini

+2-4
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ wheel_build_env = .pkg
2121
extras =
2222
testing
2323
passenv =
24-
PYTEST_*
24+
PYTEST_ADDOPTS
2525
setenv =
2626
COVERAGE_FILE = {toxworkdir}{/}.coverage.{envname}
2727
commands =
@@ -38,8 +38,6 @@ basepython = python3.10
3838
skip_install = true
3939
deps =
4040
pre-commit>=3.2.1
41-
passenv =
42-
*
4341
commands =
4442
pre-commit run --all-files --show-diff-on-failure
4543
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
8583
extras =
8684
docs
8785
commands =
88-
sphinx-build -d "{envtmpdir}{/}doctree" docs "{toxworkdir}{/}docs_out" --color -b html {posargs}
86+
sphinx-build -d "{envtmpdir}{/}doctree" docs "{toxworkdir}{/}docs_out" --color -b html -W {posargs}
8987
python -c 'print(r"documentation available under file://{toxworkdir}{/}docs_out{/}index.html")'
9088

9189
[testenv:readme]

whitelist.txt

+4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
1+
addnodes
12
autoclass
23
autodoc
34
autosectionlabel
45
caplog
6+
contnode
7+
docutils
58
eacces
69
enosys
710
extlinks
811
fchmod
912
filelock
1013
filemode
14+
fromdocname
1115
fspath
1216
getframeinfo
1317
intersphinx

0 commit comments

Comments
 (0)