From: Vladimír Vondruš Date: Thu, 18 Jan 2018 12:10:29 +0000 (+0100) Subject: m.gl: ability to link to WebGL extensions. X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~cjwatson/git?a=commitdiff_plain;h=7565fc793f0eaecafec37139d991c1dff8726637;p=blog.git m.gl: ability to link to WebGL extensions. --- diff --git a/doc/plugins/links.rst b/doc/plugins/links.rst index 4b22139d..f39d1285 100644 --- a/doc/plugins/links.rst +++ b/doc/plugins/links.rst @@ -110,14 +110,16 @@ including the ``m/`` directory into one of your :py:`PLUGIN_PATHS` and add PLUGINS += ['m.gl'] Use the :rst:`:glfn:` interpreted text role for linking to functions, -:rst:`:glext:` for linking to extensions and :rst:`:glfnext:` for linking to -extension functions. In the link target the leading ``gl`` prefix of functions -and the leading ``GL_`` prefix of extensions is prepended automatically. +:rst:`:glext:` for linking to OpenGL / OpenGL ES extensions, :rst:`:webglext:` +for linking to WebGL extensions and :rst:`:glfnext:` for linking to extension +functions. In the link target the leading ``gl`` prefix of functions and the +leading ``GL_`` prefix of extensions is prepended automatically. Link text is equal to full function name including the ``gl`` prefix and ``()`` for functions, equal to extension name or equal to extension function -link, including the vendor suffix. For :rst:`:glfn:` and :rst:`:glext:` it's -possible to specify alternate link text using the well-known syntax. +link, including the vendor suffix. For :rst:`:glfn:`, :rst:`:glext:` and +:rst:`:webglext:` it's possible to specify alternate link text using the +well-known syntax. .. code-figure:: @@ -125,11 +127,13 @@ possible to specify alternate link text using the well-known syntax. - Function link: :glfn:`DispatchCompute` - Extension link: :glext:`ARB_direct_state_access` + - WebGL extension link: :webglext:`OES_texture_float` - Extension function link: :glfnext:`SpecializeShader ` - :glfn:`Custom link title ` - Function link: :glfn:`DispatchCompute` - Extension link: :glext:`ARB_direct_state_access` + - WebGL extension link: :webglext:`OES_texture_float` - Extension function link: :glfnext:`SpecializeShader ` - :glfn:`Custom link title ` diff --git a/pelican-plugins/m/gl.py b/pelican-plugins/m/gl.py index bb36dab8..7ef8071a 100644 --- a/pelican-plugins/m/gl.py +++ b/pelican-plugins/m/gl.py @@ -34,6 +34,13 @@ def glext(name, rawtext, text, lineno, inliner, options={}, content=[]): node = nodes.reference(rawtext, title, refuri=url, **options) return [node], [] +def webglext(name, rawtext, text, lineno, inliner, options={}, content=[]): + title, extension = parse_link(text) + if not title: title = extension + url = "https://www.khronos.org/registry/webgl/extensions/{}/".format(extension) + node = nodes.reference(rawtext, title, refuri=url, **options) + return [node], [] + def glfn(name, rawtext, text, lineno, inliner, options={}, content=[]): title, fn = parse_link(text) if not title: title = "gl{}()".format(fn) @@ -50,5 +57,6 @@ def glfnext(name, rawtext, text, lineno, inliner, options={}, content=[]): def register(): rst.roles.register_local_role('glext', glext) + rst.roles.register_local_role('webglext', webglext) rst.roles.register_local_role('glfn', glfn) rst.roles.register_local_role('glfnext', glfnext) diff --git a/pelican-plugins/m/test/gl/page.html b/pelican-plugins/m/test/gl/page.html index 9ae1fd4e..9676821c 100644 --- a/pelican-plugins/m/test/gl/page.html +++ b/pelican-plugins/m/test/gl/page.html @@ -26,6 +26,7 @@ diff --git a/pelican-plugins/m/test/gl/page.rst b/pelican-plugins/m/test/gl/page.rst index 3ec3f93e..efe36130 100644 --- a/pelican-plugins/m/test/gl/page.rst +++ b/pelican-plugins/m/test/gl/page.rst @@ -3,5 +3,6 @@ m.gl - Function link: :glfn:`DispatchCompute` - Extension link: :glext:`ARB_direct_state_access` +- WebGL extension link: :webglext:`OES_texture_float` - Extension function link: :glfnext:`SpecializeShader ` - :glfn:`Custom link title `