From 923a41ac9998fa1edf0693f3215d0664a7867ba7 Mon Sep 17 00:00:00 2001 From: Erik Faye-Lund Date: Thu, 9 Mar 2023 14:22:11 +0100 Subject: [PATCH] docs: implement new vk-feat role This makes it easy to link to a specific Vulkan feature from the docs. Useful for the Zink docs. Acked-by: Mike Blumenkrantz Part-of: --- docs/_exts/formatting.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/docs/_exts/formatting.py b/docs/_exts/formatting.py index 027662552c2..ad40a7bd3a7 100644 --- a/docs/_exts/formatting.py +++ b/docs/_exts/formatting.py @@ -33,7 +33,17 @@ def ext_role(name, rawtext, text, lineno, inliner, options={}, content=[]): pnode = nodes.reference(title, title, internal=False, refuri=full_url) return [pnode], [] +def vkfeat_role(name, rawtext, text, lineno, inliner, options={}, content=[]): + text = utils.unescape(text) + has_explicit_title, title, ext = split_explicit_title(text) + + full_url = f'https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#features-{ext}' + + pnode = nodes.reference(title, title, internal=False, refuri=full_url) + return [pnode], [] + def setup(app): app.add_object_type("opcode", "opcode", "%s (TGSI opcode)", parse_opcode) app.add_role('ext', ext_role) + app.add_role('vk-feat', vkfeat_role)