diff options
-rw-r--r-- | docs/api/jsonschema/index.rst | 3 | ||||
-rw-r--r-- | docs/conf.py | 27 | ||||
-rw-r--r-- | jsonschema/_format.py | 1 |
3 files changed, 31 insertions, 0 deletions
diff --git a/docs/api/jsonschema/index.rst b/docs/api/jsonschema/index.rst index 21ba070..ebf4c8a 100644 --- a/docs/api/jsonschema/index.rst +++ b/docs/api/jsonschema/index.rst @@ -17,3 +17,6 @@ Package summary .. automodule:: jsonschema :members: :imported-members: + + +.. autodata:: jsonschema._format._F diff --git a/docs/conf.py b/docs/conf.py index 3f1f4a9..d691aaf 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -36,6 +36,33 @@ pygments_dark_style = "one-dark" html_theme = "furo" +# See sphinx-doc/sphinx#10785 +_TYPE_ALIASES = { + "jsonschema._format._F", # format checkers +} + + +def _resolve_type_aliases(app, env, node, contnode): + if ( + node["refdomain"] == "py" + and node["reftype"] == "class" + and node["reftarget"] in _TYPE_ALIASES + ): + return app.env.get_domain("py").resolve_xref( + env, + node["refdoc"], + app.builder, + "data", + node["reftarget"], + node, + contnode, + ) + + +def setup(app): + app.connect("missing-reference", _resolve_type_aliases) + + # = Builders = doctest_global_setup = """ diff --git a/jsonschema/_format.py b/jsonschema/_format.py index 5ec9797..6a7f4a8 100644 --- a/jsonschema/_format.py +++ b/jsonschema/_format.py @@ -11,6 +11,7 @@ import warnings from jsonschema.exceptions import FormatError _FormatCheckCallable = typing.Callable[[object], bool] +#: A format checker callable. _F = typing.TypeVar("_F", bound=_FormatCheckCallable) _RaisesType = typing.Union[ typing.Type[Exception], typing.Tuple[typing.Type[Exception], ...], |