chiark / gitweb /
plugins: make it possible to specify classes on all link roles.
authorVladimír Vondruš <mosra@centrum.cz>
Sun, 26 Aug 2018 15:52:34 +0000 (17:52 +0200)
committerVladimír Vondruš <mosra@centrum.cz>
Sun, 26 Aug 2018 15:52:34 +0000 (17:52 +0200)
19 files changed:
doc/plugins/links.rst
pelican-plugins/m/abbr.py
pelican-plugins/m/dox.py
pelican-plugins/m/filesize.py
pelican-plugins/m/gh.py
pelican-plugins/m/gl.py
pelican-plugins/m/test/abbr/page.html
pelican-plugins/m/test/abbr/page.rst
pelican-plugins/m/test/dox/page.html
pelican-plugins/m/test/dox/page.rst
pelican-plugins/m/test/filesize/page.html
pelican-plugins/m/test/filesize/page.rst
pelican-plugins/m/test/gh/page.html
pelican-plugins/m/test/gh/page.rst
pelican-plugins/m/test/gl/page.html
pelican-plugins/m/test/gl/page.rst
pelican-plugins/m/test/vk/page.html
pelican-plugins/m/test/vk/page.rst
pelican-plugins/m/vk.py

index bd355ac3ca5a0d460daa54a8e65db9edf366179c..d9f3ed5b190723b2ebda0a345f53456058d329f3 100644 (file)
@@ -72,12 +72,16 @@ one slash, the target is simply prepended with ``https://github.com/``.
 Link text is equal to link target for repository, commit and issue/PR links,
 otherwise the full expanded URL is used. Similarly to builtin linking
 functionality, if you want a custom text for a link, use the
-:rst:`:gh:`link text <link-target>`` syntax.
+:rst:`:gh:`link text <link-target>`` syntax. It's also possible to add custom
+CSS classes by deriving the role and adding the :rst:`:class:` option.
 
 .. code-figure::
 
     .. code:: rst
 
+        .. role:: gh-flat(gh)
+            :class: m-flat
+
         -   Profile link: :gh:`mosra`
         -   Repository link: :gh:`mosra/m.css`
         -   Commit link: :gh:`mosra/m.css@4d362223f107cffd8731a0ea031f9353a0a2c7c4`
@@ -87,6 +91,10 @@ functionality, if you want a custom text for a link, use the
         -   File link: :gh:`mosra/m.css$master/css/m-dark.css`
         -   Arbitrary link: :gh:`mosra/magnum/graphs/contributors`
         -   :gh:`Link with custom title <getpelican/pelican>`
+        -   Flat link: :gh-flat:`mosra`
+
+    .. role:: gh-flat(gh)
+        :class: m-flat
 
     -   Profile link: :gh:`mosra`
     -   Repository link: :gh:`mosra/m.css`
@@ -97,6 +105,7 @@ functionality, if you want a custom text for a link, use the
     -   File link: :gh:`mosra/m.css$master/css/m-dark.css`
     -   Arbitrary link: :gh:`mosra/magnum/graphs/contributors`
     -   :gh:`Link with custom title <getpelican/pelican>`
+    -   Flat link: :gh-flat:`mosra`
 
 `OpenGL functions and extensions`_
 ==================================
@@ -119,23 +128,32 @@ 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:`, :rst:`:glext:` and
 :rst:`:webglext:` it's possible to specify alternate link text using the
-well-known syntax.
+well-known syntax. Adding custom CSS classes can be done by deriving the role
+and adding the :rst:`:class:` option.
 
 .. code-figure::
 
     .. code:: rst
 
+        .. role:: glfn-flat(glfn)
+            :class: m-flat
+
         -   Function link: :glfn:`DispatchCompute`
         -   Extension link: :glext:`ARB_direct_state_access`
         -   WebGL extension link: :webglext:`OES_texture_float`
         -   Extension function link: :glfnext:`SpecializeShader <ARB_gl_spirv>`
         -   :glfn:`Custom link title <DrawElementsIndirect>`
+        -   Flat link: :glfn-flat:`DrawElements`
+
+    .. role:: glfn-flat(glfn)
+        :class: m-flat
 
     -   Function link: :glfn:`DispatchCompute`
     -   Extension link: :glext:`ARB_direct_state_access`
     -   WebGL extension link: :webglext:`OES_texture_float`
     -   Extension function link: :glfnext:`SpecializeShader <ARB_gl_spirv>`
     -   :glfn:`Custom link title <DrawElementsIndirect>`
+    -   Flat link: :glfn-flat:`DrawElements`
 
 `Vulkan functions and extensions`_
 ==================================
@@ -162,17 +180,25 @@ possible to specify alternate link text using the well-known syntax.
 
     .. code:: rst
 
+        .. role:: vkfn-flat(vkfn)
+            :class: m-flat
+
         -   Function link: :vkfn:`CreateInstance`
         -   Type link: :vktype:`InstanceCreateInfo`
         -   Definition link: :vktype:`VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO <StructureType>`
         -   Extension link: :vkext:`KHR_swapchain`
         -   :vkfn:`Custom link title <DestroyInstance>`
+        -   Flat link :vkfn-flat:`DestroyDevice`
+
+    .. role:: vkfn-flat(vkfn)
+        :class: m-flat
 
     -   Function link: :vkfn:`CreateInstance`
     -   Type link: :vktype:`InstanceCreateInfo`
     -   Definition link: :vktype:`VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO <StructureType>`
     -   Extension link: :vkext:`KHR_swapchain`
     -   :vkfn:`Custom link title <DestroyInstance>`
+    -   Flat link :vkfn-flat:`DestroyDevice`
 
 `Doxygen documentation`_
 ========================
@@ -209,18 +235,26 @@ just the title is rendered, as normal text). You can append ``#anchor`` to
 ``link-target`` to link to anchors that are not present in the tag file (such
 as ``#details`` for the detailed docs or ``#pub-methods`` for jumping straight
 to a list of public member functions), the same works for query parameters
-starting with ``?``.
+starting with ``?``. Adding custom CSS classes can be done by deriving the role
+and adding the :rst:`:class:` option.
 
 .. code-figure::
 
     .. code:: rst
 
+        .. role:: dox-flat(dox)
+            :class: m-flat
+
         -   Function link: :dox:`Utility::Directory::mkpath()`
         -   Class link: :dox:`Interconnect::Emitter`
         -   Page link: :dox:`building-corrade`
         -   :dox:`Custom link title <testsuite>`
         -   :dox:`Link to documentation index page <corrade>`
         -   :dox:`Link to an anchor <Interconnect::Emitter#pub-methods>`
+        -   Flat link: :dox-flat:`plugin-management`
+
+    .. role:: dox-flat(dox)
+        :class: m-flat
 
     -   Function link: :dox:`Utility::Directory::mkpath()`
     -   Class link: :dox:`Interconnect::Emitter`
@@ -228,6 +262,7 @@ starting with ``?``.
     -   :dox:`Custom link title <testsuite>`
     -   :dox:`Link to documentation index page <corrade>`
     -   :dox:`Link to an anchor <Interconnect::Emitter#pub-methods>`
+    -   Flat link: :dox-flat:`plugin-management`
 
 .. note-success::
 
@@ -256,16 +291,23 @@ and makes its syntax consistent with other common roles of :abbr:`reST <reStruct
 and m.css.
 
 Use the :rst:`:abbr:` interpreted text role for creating abbreviations with
-title in angle brackets:
+title in angle brackets. Adding custom CSS classes can be done by deriving the
+role and adding the :rst:`:class:` option.
 
 .. code-figure::
 
     .. code:: rst
 
-        :abbr:`HTML <HyperText Markup Language>` and :abbr:`CSS <Cascading Style Sheets>`
+        .. role:: abbr-warning(abbr)
+            :class: m-text m-warning
+
+        :abbr:`HTML <HyperText Markup Language>` and :abbr-warning:`CSS <Cascading Style Sheets>`
         are *all you need* for producing rich content-oriented websites.
 
-    :abbr:`HTML <HyperText Markup Language>` and :abbr:`CSS <Cascading Style Sheets>`
+    .. role:: abbr-warning(abbr)
+        :class: m-text m-warning
+
+    :abbr:`HTML <HyperText Markup Language>` and :abbr-warning:`CSS <Cascading Style Sheets>`
     are *all you need* for producing rich content-oriented websites.
 
 `File size queries`_
@@ -284,20 +326,27 @@ including the ``m/`` directory into one of your :py:`PLUGIN_PATHS` and add
 
 Use the :rst:`filesize` interpreted text role to display the size of a file
 including units. The :rst:`filesize-gz` role compresses the file using GZip
-first before calculating the size.
+first before calculating the size. Adding custom CSS classes can be done by
+deriving the role and adding the :rst:`:class:` option.
 
 .. code-figure::
 
     .. code:: rst
 
+        .. role:: filesize-yay(filesize-gz)
+            :class: m-text m-success
+
         The compiled ``m-dark.compiled.css`` CSS file has
         :filesize:`{filename}/../css/m-dark.compiled.css` but only
-        :filesize-gz:`{filename}/../css/m-dark.compiled.css` when the server
+        :filesize-yay:`{filename}/../css/m-dark.compiled.css` when the server
         sends it compressed.
 
+    .. role:: filesize-yay(filesize-gz)
+        :class: m-text m-success
+
     The compiled ``m-dark.compiled.css`` CSS file has
     :filesize:`{filename}/../css/m-dark.compiled.css` but only
-    :filesize-gz:`{filename}/../css/m-dark.compiled.css` when the server
+    :filesize-yay:`{filename}/../css/m-dark.compiled.css` when the server
     sends it compressed.
 
 `Aliases`_
index 219f9dcbc22f705983162477e1caafad8027e60f..812e12a8a91d038c57d4a4419c8f4404faac1f67 100644 (file)
@@ -25,6 +25,7 @@
 import re
 from docutils import nodes, utils
 from docutils.parsers import rst
+from docutils.parsers.rst.roles import set_classes
 
 # to avoid dependencies, link_regexp and parse_link() is common for m.abbr,
 # m.gh, m.gl and m.vk
@@ -39,9 +40,10 @@ def parse_link(text):
 
 def abbr(name, rawtext, text, lineno, inliner, options={}, content=[]):
     abbr, title = parse_link(text)
+    set_classes(options)
     if not abbr:
-        return [nodes.abbreviation(title, title)], []
-    return [nodes.abbreviation(abbr, abbr, title=title)], []
+        return [nodes.abbreviation(title, title, **options)], []
+    return [nodes.abbreviation(abbr, abbr, title=title, **options)], []
 
 def register():
     rst.roles.register_local_role('abbr', abbr)
index 4063841be1411dd677654144fee9ea68d71ef201..8cda075c2b34f23dfc0a7624415674a6b4243f3e 100644 (file)
@@ -25,6 +25,8 @@
 from docutils.parsers.rst.states import Inliner
 from docutils import nodes, utils
 from docutils.parsers import rst
+from docutils.parsers.rst.roles import set_classes
+
 from pelican import signals
 import xml.etree.ElementTree as ET
 import os
@@ -116,6 +118,8 @@ def init(pelicanobj):
 def dox(name, rawtext, text, lineno, inliner: Inliner, options={}, content=[]):
     title, target, hash = parse_link(text)
 
+    set_classes(options)
+
     # Try linking to the whole docs first
     for basename, url in tagfile_basenames:
         if basename == target:
index 60c8afa098781310dfffbdf99098365645c0262c..ad85428d9947e7d3a7019466bb2e0bd2023699a2 100644 (file)
@@ -26,6 +26,7 @@ import os
 import gzip
 from docutils import nodes
 from docutils.parsers import rst
+from docutils.parsers.rst.roles import set_classes
 from pelican import signals
 
 settings = {}
@@ -44,7 +45,8 @@ def filesize(name, rawtext, text, lineno, inliner, options={}, content=[]):
         size /= 1024.0
     else: size_string = "%.1f PB" % size
 
-    return [nodes.inline(size_string, size_string)], []
+    set_classes(options)
+    return [nodes.inline(size_string, size_string, **options)], []
 
 def filesize_gz(name, rawtext, text, lineno, inliner, options={}, content=[]):
     with open(text.format(filename=os.path.join(os.getcwd(), settings['path'])), mode='rb') as f:
@@ -57,7 +59,8 @@ def filesize_gz(name, rawtext, text, lineno, inliner, options={}, content=[]):
         size /= 1024.0
     else: size_string = "%.1f PB" % size
 
-    return [nodes.inline(size_string, size_string)], []
+    set_classes(options)
+    return [nodes.inline(size_string, size_string, **options)], []
 
 def register():
     signals.initialized.connect(init)
index 689a55ab507e6b8544b1a146603f77fd3d860e0c..a74ace4f32e08a5f35567996f24a2f63bd2e40dd 100644 (file)
@@ -25,6 +25,7 @@
 import re
 from docutils import nodes, utils
 from docutils.parsers import rst
+from docutils.parsers.rst.roles import set_classes
 
 # to avoid dependencies, link_regexp and parse_link() is common for m.abbr,
 # m.gh, m.gl and m.vk
@@ -72,6 +73,7 @@ def gh(name, rawtext, text, lineno, inliner, options={}, content=[]):
     else:
         title, url = gh_internal(account, ref, title, link)
 
+    set_classes(options)
     node = nodes.reference(rawtext, title, refuri=url, **options)
     return [node], []
 
index 01f9b84ce99f0485e52e8976b14f59b158e720e6..0e89331fca076c4643a5952f4af9577f82a9cef8 100644 (file)
@@ -25,6 +25,7 @@
 import re
 from docutils import nodes, utils
 from docutils.parsers import rst
+from docutils.parsers.rst.roles import set_classes
 
 # to avoid dependencies, link_regexp and parse_link() is common for m.abbr,
 # m.gh, m.gl and m.vk
@@ -42,6 +43,7 @@ def glext(name, rawtext, text, lineno, inliner, options={}, content=[]):
     if not title: title = extension
     prefix = extension.partition('_')[0]
     url = "https://www.khronos.org/registry/OpenGL/extensions/{}/{}.txt".format(prefix, extension)
+    set_classes(options)
     node = nodes.reference(rawtext, title, refuri=url, **options)
     return [node], []
 
@@ -49,6 +51,7 @@ 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)
+    set_classes(options)
     node = nodes.reference(rawtext, title, refuri=url, **options)
     return [node], []
 
@@ -56,6 +59,7 @@ def glfn(name, rawtext, text, lineno, inliner, options={}, content=[]):
     title, fn = parse_link(text)
     if not title: title = "gl{}()".format(fn)
     url = "https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/gl{}.xhtml".format(fn)
+    set_classes(options)
     node = nodes.reference(rawtext, title, refuri=url, **options)
     return [node], []
 
@@ -63,6 +67,7 @@ def glfnext(name, rawtext, text, lineno, inliner, options={}, content=[]):
     title, extension = parse_link(text)
     prefix = extension.partition('_')[0]
     url = "https://www.khronos.org/registry/OpenGL/extensions/{}/{}.txt".format(prefix, extension)
+    set_classes(options)
     node = nodes.reference(rawtext, "gl" + title + prefix + "()", refuri=url, **options)
     return [node], []
 
index 4a121abf91df7a6d3dfbe7f100f90e4b2bb6925b..bcf66a6fd85513ec5d3ce81c17ab80c584326621 100644 (file)
@@ -23,7 +23,7 @@
       <div class="m-col-l-10 m-push-l-1">
         <h1>m.abbr</h1>
 <!-- content -->
-<p><abbr title="Title">Text</abbr>. <abbr>Text</abbr>.</p>
+<p><abbr title="Title">Text</abbr>. <abbr>Text</abbr>. <abbr class="m-text m-strong" title="STRONGG!">Strong Abbr</abbr>.</p>
 <!-- /content -->
       </div>
     </div>
index 2d8118aa643f4f7a551ccbb4292c18c79781e3a8..d277ad0f25ac969a6d6fc094ef26c22b334f4867 100644 (file)
@@ -1,4 +1,7 @@
 m.abbr
 ######
 
-:abbr:`Text <Title>`. :abbr:`Text`.
+.. role:: abbr-strong(abbr)
+    :class: m-text m-strong
+
+:abbr:`Text <Title>`. :abbr:`Text`. :abbr-strong:`Strong Abbr <STRONGG!>`.
index aad6bd634885bca405afbf1dc919bcdf3c05b578..33e05c4e755ca6e1938339e4a2dfc97895c84a3c 100644 (file)
@@ -34,6 +34,7 @@
 <li><a href="http://doc.magnum.graphics/corrade/#search">Link to index page with hash after</a></li>
 <li><a href="http://doc.magnum.graphics/corrade/corrade-cmake.html#search">Link to page with hash after</a></li>
 <li><a href="http://doc.magnum.graphics/corrade/namespaceCorrade_1_1Utility_1_1Directory.html?q=hello#search">Link to class with query and hash after</a></li>
+<li>Flat link: <a class="m-flat" href="http://doc.magnum.graphics/corrade/plugin-management.html">Plugin management tutorial</a></li>
 </ul>
 <p>These should produce warnings:</p>
 <ul>
index f401ccf99101fd4e24817509d3db2c139814ac96..a9f09cd4bed6d6da7fb90c0e15403db56e57cc5b 100644 (file)
@@ -1,6 +1,9 @@
 m.dox
 #####
 
+.. role:: dox-flat(dox)
+    :class: m-flat
+
 -   Function link: :dox:`Utility::Directory::mkpath()`
 -   Class link: :dox:`Interconnect::Emitter`
 -   Page link: :dox:`building-corrade`
@@ -11,6 +14,7 @@ m.dox
 -   :dox:`Link to index page with hash after <corrade#search>`
 -   :dox:`Link to page with hash after <corrade-cmake#search>`
 -   :dox:`Link to class with query and hash after <Utility::Directory?q=hello#search>`
+-   Flat link: :dox-flat:`plugin-management`
 
 These should produce warnings:
 
index b7ea6e59f1af38afd03b8ffb8b961775fddfc276..a4aab6f839f31148ffe1112dad664fe692ca0f57 100644 (file)
@@ -23,8 +23,9 @@
       <div class="m-col-l-10 m-push-l-1">
         <h1>m.filesize</h1>
 <!-- content -->
-<p>This file has <span>117.0 B</span> and <span>91.0 B</span>
-gzipped.</p>
+<p>This file has <span>342.0 B</span> and <span>177.0 B</span>
+gzipped. I mean, <span class="m-text m-success">177.0 B</span> is good, but
+<span class="m-text m-danger">342.0 B</span> not.</p>
 <!-- /content -->
       </div>
     </div>
index c247d02deca152539a3c1022cbb85c833991c5c0..0c79fa8def27bb0fe23fac001af9042b7882b8f7 100644 (file)
@@ -1,5 +1,11 @@
 m.filesize
 ##########
 
+.. role:: filesize-nay(filesize)
+    :class: m-text m-danger
+.. role:: filesize-yay(filesize-gz)
+    :class: m-text m-success
+
 This file has :filesize:`{filename}/page.rst` and :filesize-gz:`{filename}/page.rst`
-gzipped.
+gzipped. I mean, :filesize-yay:`{filename}/page.rst` is good, but
+:filesize-nay:`{filename}/page.rst` not.
index 5d7332ab03efc3faca526d19ae2b29cad6169b5f..9f9f39760a4288d08c769684904edae4c2773358 100644 (file)
@@ -33,6 +33,7 @@
 <li>File link: <a href="https://github.com/mosra/m.css/tree/master/css/m-dark.css">https://github.com/mosra/m.css/tree/master/css/m-dark.css</a></li>
 <li>Arbitrary link: <a href="https://github.com/mosra/magnum/graphs/contributors">https://github.com/mosra/magnum/graphs/contributors</a></li>
 <li><a href="https://github.com/getpelican/pelican">Link with custom title</a></li>
+<li>Flat link: <a class="m-flat" href="https://github.com/mosra">&#64;mosra</a></li>
 </ul>
 <!-- /content -->
       </div>
index 0d278371f8aeda0c40efd6ed2da7f4feb8f469e6..4a0a388b2a2bceaef06c775842351a4de25be987 100644 (file)
@@ -1,6 +1,9 @@
 m.gh
 ####
 
+.. role:: gh-flat(gh)
+    :class: m-flat
+
 -   Profile link: :gh:`mosra`
 -   Repository link: :gh:`mosra/m.css`
 -   Commit link: :gh:`mosra/m.css@4d362223f107cffd8731a0ea031f9353a0a2c7c4`
@@ -10,3 +13,4 @@ m.gh
 -   File link: :gh:`mosra/m.css$master/css/m-dark.css`
 -   Arbitrary link: :gh:`mosra/magnum/graphs/contributors`
 -   :gh:`Link with custom title <getpelican/pelican>`
+-   Flat link: :gh-flat:`mosra`
index 9676821cc1ea8a84b8cbc65da1bef47a0dfef713..20b763bfd8f6ab780621ea00262aa36a594d1760 100644 (file)
@@ -29,6 +29,7 @@
 <li>WebGL extension link: <a href="https://www.khronos.org/registry/webgl/extensions/OES_texture_float/">OES_texture_float</a></li>
 <li>Extension function link: <a href="https://www.khronos.org/registry/OpenGL/extensions/ARB/ARB_gl_spirv.txt">glSpecializeShaderARB()</a></li>
 <li><a href="https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glDrawElementsIndirect.xhtml">Custom link title</a></li>
+<li>Flat link: <a class="m-flat" href="https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glDrawElements.xhtml">glDrawElements()</a></li>
 </ul>
 <!-- /content -->
       </div>
index efe36130292c620f1a6cff44c0db8c332dfb10e6..ebcc04e263b6e3a6381c127842bcc1d945bb044c 100644 (file)
@@ -1,8 +1,12 @@
 m.gl
 ####
 
+.. role:: glfn-flat(glfn)
+    :class: m-flat
+
 -   Function link: :glfn:`DispatchCompute`
 -   Extension link: :glext:`ARB_direct_state_access`
 -   WebGL extension link: :webglext:`OES_texture_float`
 -   Extension function link: :glfnext:`SpecializeShader <ARB_gl_spirv>`
 -   :glfn:`Custom link title <DrawElementsIndirect>`
+-   Flat link: :glfn-flat:`DrawElements`
index b5003d3a23de95ac2d250c73309c768daff00e22..0235f51d47be852f115cdd2e9d05c4015f1e3d5c 100644 (file)
@@ -29,6 +29,7 @@
 <li>Definition link: <a href="https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/VkStructureType.html">VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO</a></li>
 <li>Extension link: <a href="https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#VK_KHR_swapchain">KHR_swapchain</a></li>
 <li><a href="https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkDestroyInstance.html">Custom link title</a></li>
+<li>Flat link <a class="m-flat" href="https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkDestroyDevice.html">vkDestroyDevice()</a></li>
 </ul>
 <!-- /content -->
       </div>
index 2bc76cddac3471f255a3d69f54bb4c13e781e8c7..d9dbd8d59bbe1bf3abba9b2e97d2df248c053e4a 100644 (file)
@@ -1,8 +1,12 @@
 m.vk
 ####
 
+.. role:: vkfn-flat(vkfn)
+    :class: m-flat
+
 -   Function link: :vkfn:`CreateInstance`
 -   Type link: :vktype:`InstanceCreateInfo`
 -   Definition link: :vktype:`VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO <StructureType>`
 -   Extension link: :vkext:`KHR_swapchain`
 -   :vkfn:`Custom link title <DestroyInstance>`
+-   Flat link :vkfn-flat:`DestroyDevice`
index 7eba3d6d8b8ac8605602e406ef9fc46810b839e1..8fad35f2cf4f531a0a4b351de7d332d5fdaa2536 100644 (file)
@@ -25,6 +25,7 @@
 import re
 from docutils import nodes, utils
 from docutils.parsers import rst
+from docutils.parsers.rst.roles import set_classes
 
 # to avoid dependencies, link_regexp and parse_link() is common for m.abbr,
 # m.gh, m.gl and m.vk
@@ -41,6 +42,7 @@ def vkext(name, rawtext, text, lineno, inliner, options={}, content=[]):
     title, extension = parse_link(text)
     if not title: title = extension
     url = "https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#VK_{}".format(extension)
+    set_classes(options)
     node = nodes.reference(rawtext, title, refuri=url, **options)
     return [node], []
 
@@ -48,6 +50,7 @@ def vkfn(name, rawtext, text, lineno, inliner, options={}, content=[]):
     title, fn = parse_link(text)
     if not title: title = "vk{}()".format(fn)
     url = "https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vk{}.html".format(fn)
+    set_classes(options)
     node = nodes.reference(rawtext, title, refuri=url, **options)
     return [node], []
 
@@ -55,6 +58,7 @@ def vktype(name, rawtext, text, lineno, inliner, options={}, content=[]):
     title, fn = parse_link(text)
     if not title: title = "Vk{}".format(fn)
     url = "https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/Vk{}.html".format(fn)
+    set_classes(options)
     node = nodes.reference(rawtext, title, refuri=url, **options)
     return [node], []