chiark / gitweb /
plugins: new m.vk plugin.
authorVladimír Vondruš <mosra@centrum.cz>
Mon, 4 Jun 2018 07:21:40 +0000 (09:21 +0200)
committerVladimír Vondruš <mosra@centrum.cz>
Mon, 4 Jun 2018 07:24:12 +0000 (09:24 +0200)
doc/plugins.rst
doc/plugins/links.rst
pelican-plugins/m/abbr.py
pelican-plugins/m/gh.py
pelican-plugins/m/gl.py
pelican-plugins/m/test/test_vk.py [new file with mode: 0644]
pelican-plugins/m/test/vk/page.html [new file with mode: 0644]
pelican-plugins/m/test/vk/page.rst [new file with mode: 0644]
pelican-plugins/m/vk.py [new file with mode: 0644]
site/pelicanconf.py

index afb54bbd5e1a0ff5dc3380045c0dc341d1aec708..9a4de1efd578030a1b6fe68358f3258d7467cdf6 100644 (file)
@@ -49,6 +49,7 @@ and restart Pelican. Download the plugins below or
 -   :gh:`m.gh <mosra/m.css$master/pelican-plugins/m/gh.py>`,
     :gh:`m.dox <mosra/m.css$master/pelican-plugins/m/dox.py>`,
     :gh:`m.gl <mosra/m.css$master/pelican-plugins/m/gl.py>`,
+    :gh:`m.vk <mosra/m.css$master/pelican-plugins/m/vk.py>`,
     :gh:`m.abbr <mosra/m.css$master/pelican-plugins/m/abbr.py>`,
     :gh:`m.filesize <mosra/m.css$master/pelican-plugins/m/filesize.py>`,
     :gh:`m.alias <mosra/m.css$master/pelican-plugins/m/alias.py>`
@@ -97,10 +98,10 @@ as an inline SVG and can be styled using CSS like everything else.
 `Links and other » <{filename}/plugins/links.rst>`_
 ===================================================
 
-The :py:`m.gh`, :py:`m.dox`, :py:`m.gl`, :py:`m.abbr`, :py:`m.fiilesize` and
-:py:`m.alias` plugins make it easy for you to link to GitHub projects, issues
-or PRs, to Doxygen documentation, query file sizes and provide URL aliases to
-preserve link compatibility.
+The :py:`m.gh`, :py:`m.dox`, :py:`m.gl`, :py:`m.vk`, :py:`m.abbr`,
+:py:`m.fiilesize` and :py:`m.alias` plugins make it easy for you to link to
+GitHub projects, issues or PRs, to Doxygen documentation, query file sizes and
+provide URL aliases to preserve link compatibility.
 
 `Metadata » <{filename}/plugins/metadata.rst>`_
 ===============================================
index eb57a94dcbceeeb776bebed3dcbd28585ec64f04..6ee440009f1153d8a46ad8f2b7cb8451a6e97d44 100644 (file)
@@ -137,6 +137,43 @@ well-known syntax.
     -   Extension function link: :glfnext:`SpecializeShader <ARB_gl_spirv>`
     -   :glfn:`Custom link title <DrawElementsIndirect>`
 
+`Vulkan functions and extensions`_
+==================================
+
+Download the `m/vk.py <{filename}/plugins.rst>`_ file, put it
+including the ``m/`` directory into one of your :py:`PLUGIN_PATHS` and add
+:py:`m.vk` package to your :py:`PLUGINS` in ``pelicanconf.py``:
+
+.. code:: python
+
+    PLUGINS += ['m.vk']
+
+Use the :rst:`:vkfn:` interpreted text role for linking to functions,
+:rst:`:vktype:` for linking to types and :rst:`:vkext:` for linking to
+extensions. In the link target the leading ``vk`` prefix of functions, ``Vk``
+prefix of types and the leading ``VK_`` prefix of extensions is prepended
+automatically.
+
+Link text is equal to full function name including the ``vk`` prefix and
+``()`` for functions, ``Vk`` prefix for types or equal to extension name. It's
+possible to specify alternate link text using the well-known syntax.
+
+.. code-figure::
+
+    .. code:: rst
+
+        -   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>`
+
+    -   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>`
+
 `Doxygen documentation`_
 ========================
 
index 4eb705e1bf27ccf41faddff69c977daa9ae8cda1..219f9dcbc22f705983162477e1caafad8027e60f 100644 (file)
@@ -27,7 +27,7 @@ from docutils import nodes, utils
 from docutils.parsers import rst
 
 # to avoid dependencies, link_regexp and parse_link() is common for m.abbr,
-# m.gh and m.gl
+# m.gh, m.gl and m.vk
 
 link_regexp = re.compile(r'(?P<title>.*) <(?P<link>.+)>')
 
index 422d12de0f5edd31a5e7043e60f4009b2ae52297..689a55ab507e6b8544b1a146603f77fd3d860e0c 100644 (file)
@@ -27,7 +27,7 @@ from docutils import nodes, utils
 from docutils.parsers import rst
 
 # to avoid dependencies, link_regexp and parse_link() is common for m.abbr,
-# m.gh and m.gl
+# m.gh, m.gl and m.vk
 
 link_regexp = re.compile(r'(?P<title>.*) <(?P<link>.+)>')
 
index ae61867d85faa8a452db74e2649227cf1ed2b8c2..01f9b84ce99f0485e52e8976b14f59b158e720e6 100644 (file)
@@ -27,7 +27,7 @@ from docutils import nodes, utils
 from docutils.parsers import rst
 
 # to avoid dependencies, link_regexp and parse_link() is common for m.abbr,
-# m.gh and m.gl
+# m.gh, m.gl and m.vk
 
 link_regexp = re.compile(r'(?P<title>.*) <(?P<link>.+)>')
 
diff --git a/pelican-plugins/m/test/test_vk.py b/pelican-plugins/m/test/test_vk.py
new file mode 100644 (file)
index 0000000..56ca17f
--- /dev/null
@@ -0,0 +1,36 @@
+#
+#   This file is part of m.css.
+#
+#   Copyright © 2017, 2018 Vladimír Vondruš <mosra@centrum.cz>
+#
+#   Permission is hereby granted, free of charge, to any person obtaining a
+#   copy of this software and associated documentation files (the "Software"),
+#   to deal in the Software without restriction, including without limitation
+#   the rights to use, copy, modify, merge, publish, distribute, sublicense,
+#   and/or sell copies of the Software, and to permit persons to whom the
+#   Software is furnished to do so, subject to the following conditions:
+#
+#   The above copyright notice and this permission notice shall be included
+#   in all copies or substantial portions of the Software.
+#
+#   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+#   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+#   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+#   THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+#   LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+#   FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+#   DEALINGS IN THE SOFTWARE.
+#
+
+from m.test import PluginTestCase
+
+class Vk(PluginTestCase):
+    def __init__(self, *args, **kwargs):
+        super().__init__(__file__, '', *args, **kwargs)
+
+    def test(self):
+        self.run_pelican({
+            'PLUGINS': ['m.htmlsanity', 'm.vk']
+        })
+
+        self.assertEqual(*self.actual_expected_contents('page.html'))
diff --git a/pelican-plugins/m/test/vk/page.html b/pelican-plugins/m/test/vk/page.html
new file mode 100644 (file)
index 0000000..b5003d3
--- /dev/null
@@ -0,0 +1,40 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+  <meta charset="UTF-8" />
+  <title>m.vk | A Pelican Blog</title>
+  <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,400i,600,600i" />
+  <link rel="stylesheet" href="static/m-dark.css" />
+  <link rel="canonical" href="page.html" />
+  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+</head>
+<body>
+<header><nav id="navigation">
+  <div class="m-container">
+    <div class="m-row">
+      <a href="./" id="m-navbar-brand" class="m-col-t-9 m-col-m-none m-left-m">A Pelican Blog</a>
+    </div>
+  </div>
+</nav></header>
+<main>
+<article>
+  <div class="m-container m-container-inflatable">
+    <div class="m-row">
+      <div class="m-col-l-10 m-push-l-1">
+        <h1>m.vk</h1>
+<!-- content -->
+<ul>
+<li>Function link: <a href="https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCreateInstance.html">vkCreateInstance()</a></li>
+<li>Type link: <a href="https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/VkInstanceCreateInfo.html">VkInstanceCreateInfo</a></li>
+<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>
+</ul>
+<!-- /content -->
+      </div>
+    </div>
+  </div>
+</article>
+</main>
+</body>
+</html>
diff --git a/pelican-plugins/m/test/vk/page.rst b/pelican-plugins/m/test/vk/page.rst
new file mode 100644 (file)
index 0000000..2bc76cd
--- /dev/null
@@ -0,0 +1,8 @@
+m.vk
+####
+
+-   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>`
diff --git a/pelican-plugins/m/vk.py b/pelican-plugins/m/vk.py
new file mode 100644 (file)
index 0000000..7eba3d6
--- /dev/null
@@ -0,0 +1,64 @@
+#
+#   This file is part of m.css.
+#
+#   Copyright © 2017, 2018 Vladimír Vondruš <mosra@centrum.cz>
+#
+#   Permission is hereby granted, free of charge, to any person obtaining a
+#   copy of this software and associated documentation files (the "Software"),
+#   to deal in the Software without restriction, including without limitation
+#   the rights to use, copy, modify, merge, publish, distribute, sublicense,
+#   and/or sell copies of the Software, and to permit persons to whom the
+#   Software is furnished to do so, subject to the following conditions:
+#
+#   The above copyright notice and this permission notice shall be included
+#   in all copies or substantial portions of the Software.
+#
+#   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+#   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+#   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+#   THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+#   LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+#   FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+#   DEALINGS IN THE SOFTWARE.
+#
+
+import re
+from docutils import nodes, utils
+from docutils.parsers import rst
+
+# to avoid dependencies, link_regexp and parse_link() is common for m.abbr,
+# m.gh, m.gl and m.vk
+
+link_regexp = re.compile(r'(?P<title>.*) <(?P<link>.+)>')
+
+def parse_link(text):
+    link = utils.unescape(text)
+    m = link_regexp.match(link)
+    if m: return m.group('title', 'link')
+    return None, link
+
+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)
+    node = nodes.reference(rawtext, title, refuri=url, **options)
+    return [node], []
+
+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)
+    node = nodes.reference(rawtext, title, refuri=url, **options)
+    return [node], []
+
+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)
+    node = nodes.reference(rawtext, title, refuri=url, **options)
+    return [node], []
+
+def register():
+    rst.roles.register_local_role('vkext', vkext)
+    rst.roles.register_local_role('vkfn', vkfn)
+    rst.roles.register_local_role('vktype', vktype)
index 55b845bd42626d17b8d77e532d937a1b7653b1d0..5493bdc7cac4e419e0a5ca5366f652838f784175 100644 (file)
@@ -148,7 +148,8 @@ PLUGINS = ['m.abbr',
            'm.images',
            'm.math',
            'm.metadata',
-           'm.plots']
+           'm.plots',
+           'm.vk']
 
 THEME = '../pelican-theme'
 THEME_STATIC_DIR = 'static'