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`
- 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`
- 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`_
==================================
``()`` 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`_
==================================
.. 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`_
========================
``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`
- :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::
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`_
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`_
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
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)
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
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:
import gzip
from docutils import nodes
from docutils.parsers import rst
+from docutils.parsers.rst.roles import set_classes
from pelican import signals
settings = {}
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:
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)
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
else:
title, url = gh_internal(account, ref, title, link)
+ set_classes(options)
node = nodes.reference(rawtext, title, refuri=url, **options)
return [node], []
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
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], []
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], []
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], []
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], []
<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>
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!>`.
<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>
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`
- :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:
<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>
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.
<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">@mosra</a></li>
</ul>
<!-- /content -->
</div>
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`
- 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`
<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>
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`
<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>
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`
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
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], []
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], []
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], []