summaryrefslogtreecommitdiff
path: root/docs/_exts
diff options
context:
space:
mode:
authorErik Faye-Lund <erik.faye-lund@collabora.com>2022-11-09 11:05:18 +0100
committerMarge Bot <emma+marge@anholt.net>2022-11-09 16:10:55 +0000
commitf69560bdcb96ea0fc0e7ec21c1e267afaace5b0c (patch)
tree31c713943da01d59de93c454a7ecdf65f1dda76b /docs/_exts
parentd20bfeaa89e2adf49b114ba310f8c4294a323c52 (diff)
downloadmesa-f69560bdcb96ea0fc0e7ec21c1e267afaace5b0c.tar.gz
mesa-f69560bdcb96ea0fc0e7ec21c1e267afaace5b0c.tar.bz2
mesa-f69560bdcb96ea0fc0e7ec21c1e267afaace5b0c.zip
docs: add ext-role for spec extension links
This is a custom Sphinx role that generates links to GL and VK extensions. Reviewed-by: Eric Engestrom <eric@igalia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19594>
Diffstat (limited to 'docs/_exts')
-rw-r--r--docs/_exts/formatting.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/docs/_exts/formatting.py b/docs/_exts/formatting.py
index cc6c471f117..c7322d47a58 100644
--- a/docs/_exts/formatting.py
+++ b/docs/_exts/formatting.py
@@ -6,6 +6,9 @@
import docutils.nodes
import sphinx.addnodes
+from sphinx.util.nodes import split_explicit_title
+from docutils import nodes, utils
+
def parse_envvar(env, sig, signode):
envvar, t, default = sig.split(" ", 2)
envvar = envvar.strip().upper()
@@ -26,8 +29,25 @@ def parse_opcode(env, sig, signode):
signode += sphinx.addnodes.desc_annotation(desc, desc)
return opcode
+
+def ext_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
+ text = utils.unescape(text)
+ has_explicit_title, title, ext = split_explicit_title(text)
+
+ parts = ext.split('_', 2)
+ if parts[0] == 'VK':
+ full_url = f'https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/{ext}.html'
+ elif parts[0] == 'GL':
+ full_url = f'https://registry.khronos.org/OpenGL/extensions/{parts[1]}/{parts[1]}_{parts[2]}.txt'
+ else:
+ raise Exception(f'Unexpected API: {parts[0]}')
+
+ pnode = nodes.reference(title, title, internal=False, refuri=full_url)
+ return [pnode], []
+
def setup(app):
app.add_object_type("envvar", "envvar", "%s (environment variable)",
parse_envvar)
app.add_object_type("opcode", "opcode", "%s (TGSI opcode)",
parse_opcode)
+ app.add_role('ext', ext_role)