Skip to content

Commit

Permalink
implement resolve_any_xref similarly to myst-parser
Browse files Browse the repository at this point in the history
  • Loading branch information
mmcky committed Jul 4, 2024
1 parent aadec3b commit 03eb70a
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions sphinx_proof/domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 03eb70a

Please sign in to comment.