Skip to content

Fix: #225 :Get rid of warning about inability to link to _thread._local. #226

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 6, 2023
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
29 changes: 29 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
6 changes: 2 additions & 4 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ wheel_build_env = .pkg
extras =
testing
passenv =
PYTEST_*
PYTEST_ADDOPTS
setenv =
COVERAGE_FILE = {toxworkdir}{/}.coverage.{envname}
commands =
Expand All @@ -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"))'
Expand Down Expand Up @@ -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]
Expand Down
4 changes: 4 additions & 0 deletions whitelist.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
addnodes
autoclass
autodoc
autosectionlabel
caplog
contnode
docutils
eacces
enosys
extlinks
fchmod
filelock
filemode
fromdocname
fspath
getframeinfo
intersphinx
Expand Down