chiark / gitweb /
m.dox: restore compatibility with cppreference tag files.
authorVladimír Vondruš <mosra@centrum.cz>
Mon, 1 Aug 2022 12:39:00 +0000 (14:39 +0200)
committerVladimír Vondruš <mosra@centrum.cz>
Tue, 4 Oct 2022 10:55:57 +0000 (12:55 +0200)
These put the filename into a different tag, and don't use anchors.

plugins/m/dox.py
plugins/m/test/dox/page.html
plugins/m/test/dox/page.rst
plugins/m/test/dox/page_css_classes.html
plugins/m/test/dox/stl.tag [new file with mode: 0644]
plugins/m/test/test_dox.py

index 5751cb82d06422e282f8619f2ffe36583a67326b..7af7db0a7480ea05802a43844f2fe79b287891fe 100644 (file)
@@ -92,19 +92,26 @@ def init(tagfiles, input):
                 # Linking to namespaces, structs and classes
                 if child.attrib['kind'] in ['class', 'struct', 'namespace']:
                     name = child.find('name').text
-                    link = path + child.findtext('filename') # <filename> can be empty (cppreference tag file)
+                    # The cppreference tag file has <filename> empty
+                    link = path + child.findtext('filename')
                     symbol_mapping[name] = (None, link, css_classes)
                     for member in child.findall('member'):
                         if not 'kind' in member.attrib: continue
 
+                        # In case of the cppreference tag file, <compound>
+                        # <filename> is empty, and <anchorfile> inside <member>
+                        # is used instead. Doxygen fills both, so use
+                        # <anchorfile> to cover both cases.
+                        link = path + member.find('anchorfile').text
+
                         # Typedefs, constants, variables
                         if member.attrib['kind'] in ['typedef', 'enumvalue', 'variable']:
-                            symbol_mapping[name + '::' + member.find('name').text] = (None, link + '#' + member.findtext('anchor'), css_classes)
+                            symbol_mapping[name + '::' + member.find('name').text] = (None, link + ('#' + member.findtext('anchor') if member.findtext('anchor') else ''), css_classes)
 
                         # Functions
                         if member.attrib['kind'] == 'function':
                             # <filename> can be empty (cppreference tag file)
-                            symbol_mapping[name + '::' + member.find('name').text + "()"] = (None, link + '#' + member.findtext('anchor'), css_classes)
+                            symbol_mapping[name + '::' + member.find('name').text + "()"] = (None, link + ('#' + member.findtext('anchor') if member.findtext('anchor') else ''), css_classes)
 
                         # Enums with values
                         if member.attrib['kind'] == 'enumeration':
index d2d8dfc43a73398e554a8f7e4a3ba5b3756ff803..a2c8c9bf3b77b530f8d458c743a96b0dfb3d9b5e 100644 (file)
 <li><a href="https://doc.magnum.graphics/corrade/namespaceCorrade_1_1Utility_1_1Path.html?q=hello#search">Link to class with query and hash after</a></li>
 <li>Flat link: <a class="m-flat" href="https://doc.magnum.graphics/corrade/plugin-management.html">Plugin management</a></li>
 </ul>
+<p>STL tagfile, which uses slightly different semantic:</p>
+<ul>
+<li>Function: <a href="http://en.cppreference.com/w/cpp/string/byte/memchr">std::memchr()</a></li>
+<li>Variable: <a href="http://en.cppreference.com/w/cpp/numeric/math/div">std::div_t::quot</a></li>
+</ul>
 <p>These should produce warnings:</p>
 <ul>
 <li>Link to nonexistent name will be rendered as code: <code>nonExistent()</code></li>
index b51ae0be38bcb68494b02b6b472009ae696096cd..0ddc1b6b3a5aa5e248c10ec4d70892b2f9a0f8bd 100644 (file)
@@ -23,6 +23,11 @@ m.dox
 -   :dox:`Link to class with query and hash after <Utility::Path?q=hello#search>`
 -   Flat link: :dox-flat:`plugin-management`
 
+STL tagfile, which uses slightly different semantic:
+
+-   Function: :dox:`std::memchr()`
+-   Variable: :dox:`std::div_t::quot`
+
 These should produce warnings:
 
 -   Link to nonexistent name will be rendered as code: :dox:`nonExistent()`
index fa000c637a370c4c9c764ed49c9ed57ddf0a8695..25522da294d7e382c7af5a3c40cbdc3c3c44ae1c 100644 (file)
 <li><a class="m-flat m-text m-strong" href="https://doc.magnum.graphics/corrade/namespaceCorrade_1_1Utility_1_1Path.html?q=hello#search">Link to class with query and hash after</a></li>
 <li>Flat link: <a class="m-flat m-text m-strong" href="https://doc.magnum.graphics/corrade/plugin-management.html">Plugin management</a></li>
 </ul>
+<p>STL tagfile, which uses slightly different semantic:</p>
+<ul>
+<li>Function: <a class="m-flat m-text" href="http://en.cppreference.com/w/cpp/string/byte/memchr">std::memchr()</a></li>
+<li>Variable: <a class="m-flat m-text" href="http://en.cppreference.com/w/cpp/numeric/math/div">std::div_t::quot</a></li>
+</ul>
 <p>These should produce warnings:</p>
 <ul>
 <li>Link to nonexistent name will be rendered as code: <code>nonExistent()</code></li>
diff --git a/plugins/m/test/dox/stl.tag b/plugins/m/test/dox/stl.tag
new file mode 100644 (file)
index 0000000..893b16e
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
+<!-- To avoid bloat, the following is just a cherry-picked subset of
+     stl.tag from cppreference.com, with everything needed by:
+     - plugins/m/test/dox/page.rst -->
+<tagfile>
+  <compound kind="namespace">
+    <name>std</name>
+    <filename></filename>
+    <member kind="function">
+      <type>T</type>
+      <name>memchr</name>
+      <anchorfile>cpp/string/byte/memchr</anchorfile>
+      <anchor></anchor>
+      <arglist>(T... args)</arglist>
+    </member>
+  </compound>
+  <compound kind="class">
+    <name>std::div_t</name>
+    <filename>cpp/numeric/math/div</filename>
+    <member kind="variable">
+      <type>T</type>
+      <name>quot</name>
+      <anchorfile>cpp/numeric/math/div</anchorfile>
+      <anchor></anchor>
+      <arglist></arglist>
+    </member>
+  </compound>
+</tagfile>
index e0f3f98a70da228c52e0b8935137110124cf2295..b1ae534cc7b9e4262892a4aa0780b397b0063fb1 100644 (file)
@@ -33,7 +33,8 @@ class Dox(PelicanPluginTestCase):
         self.run_pelican({
             'PLUGINS': ['m.htmlsanity', 'm.dox'],
             'M_DOX_TAGFILES': [
-                ('../doc/documentation/corrade.tag', 'https://doc.magnum.graphics/corrade/', ['Corrade::'])]
+                ('../doc/documentation/corrade.tag', 'https://doc.magnum.graphics/corrade/', ['Corrade::']),
+                ('m/test/dox/stl.tag', 'http://en.cppreference.com/w/', [])]
         })
 
         self.assertEqual(*self.actual_expected_contents('page.html'))
@@ -42,7 +43,8 @@ class Dox(PelicanPluginTestCase):
         self.run_pelican({
             'PLUGINS': ['m.htmlsanity', 'm.dox'],
             'M_DOX_TAGFILES': [
-                ('../doc/documentation/corrade.tag', 'https://doc.magnum.graphics/corrade/', ['Corrade::'], ['m-flat', 'm-text', 'm-strong'])]
+                ('../doc/documentation/corrade.tag', 'https://doc.magnum.graphics/corrade/', ['Corrade::'], ['m-flat', 'm-text', 'm-strong']),
+                ('m/test/dox/stl.tag', 'http://en.cppreference.com/w/', [], ['m-flat', 'm-text'])]
         })
 
         self.assertEqual(*self.actual_expected_contents('page.html', 'page_css_classes.html'))