From 03eb70a6f640df347bb1af48fb86a271e85bfbb3 Mon Sep 17 00:00:00 2001 From: mmcky Date: Thu, 4 Jul 2024 10:21:29 +1000 Subject: [PATCH] implement resolve_any_xref similarly to myst-parser --- sphinx_proof/domain.py | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/sphinx_proof/domain.py b/sphinx_proof/domain.py index 036f702..289e51a 100644 --- a/sphinx_proof/domain.py +++ b/sphinx_proof/domain.py @@ -92,8 +92,32 @@ def __init__(self, env: "BuildEnvironment") -> None: for node, settings in env.app.registry.enumerable_nodes.items(): self.enumerable_nodes[node] = settings - def resolve_any_xref(self, *args, **kwargs): - return [] + def resolve_any_xref( + self, + env: BuildEnvironment, + fromdocname: str, + builder: Builder, + target: str, + node: pending_xref, + contnode: Element, + ): + """ + Support for resolve_any_xref as required by myst-parser. + Roles are forwarded to the resolve_xref method, and only non None results + are returned. + """ + results = [] + for role in self.roles: + res = self.resolve_xref( + env, fromdocname, builder, role, target, node, contnode + ) + if res is None: + continue + else: + # https://www.sphinx-doc.org/en/master/extdev/domainapi.html#sphinx.domains.Domain.resolve_any_xref + res = (role.name, res) + results.append(res) + return results def resolve_xref( self,