From 26e8fdf8a39aad040e8948795b09207fa65350dc Mon Sep 17 00:00:00 2001 From: =?utf8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Mon, 1 Aug 2022 14:39:00 +0200 Subject: [PATCH] m.dox: restore compatibility with cppreference tag files. These put the filename into a different tag, and don't use anchors. --- plugins/m/dox.py | 13 ++++++++--- plugins/m/test/dox/page.html | 5 +++++ plugins/m/test/dox/page.rst | 5 +++++ plugins/m/test/dox/page_css_classes.html | 5 +++++ plugins/m/test/dox/stl.tag | 28 ++++++++++++++++++++++++ plugins/m/test/test_dox.py | 6 +++-- 6 files changed, 57 insertions(+), 5 deletions(-) create mode 100644 plugins/m/test/dox/stl.tag diff --git a/plugins/m/dox.py b/plugins/m/dox.py index 5751cb82..7af7db0a 100644 --- a/plugins/m/dox.py +++ b/plugins/m/dox.py @@ -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') # can be empty (cppreference tag file) + # The cppreference tag file has 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, + # is empty, and inside + # is used instead. Doxygen fills both, so use + # 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': # 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': diff --git a/plugins/m/test/dox/page.html b/plugins/m/test/dox/page.html index d2d8dfc4..a2c8c9bf 100644 --- a/plugins/m/test/dox/page.html +++ b/plugins/m/test/dox/page.html @@ -43,6 +43,11 @@
  • Link to class with query and hash after
  • Flat link: Plugin management
  • +

    STL tagfile, which uses slightly different semantic:

    +

    These should produce warnings:

    • Link to nonexistent name will be rendered as code: nonExistent()
    • diff --git a/plugins/m/test/dox/page.rst b/plugins/m/test/dox/page.rst index b51ae0be..0ddc1b6b 100644 --- a/plugins/m/test/dox/page.rst +++ b/plugins/m/test/dox/page.rst @@ -23,6 +23,11 @@ m.dox - :dox:`Link to class with query and hash after ` - 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()` diff --git a/plugins/m/test/dox/page_css_classes.html b/plugins/m/test/dox/page_css_classes.html index fa000c63..25522da2 100644 --- a/plugins/m/test/dox/page_css_classes.html +++ b/plugins/m/test/dox/page_css_classes.html @@ -43,6 +43,11 @@
    • Link to class with query and hash after
    • Flat link: Plugin management
    +

    STL tagfile, which uses slightly different semantic:

    +

    These should produce warnings:

    • Link to nonexistent name will be rendered as code: nonExistent()
    • diff --git a/plugins/m/test/dox/stl.tag b/plugins/m/test/dox/stl.tag new file mode 100644 index 00000000..893b16e2 --- /dev/null +++ b/plugins/m/test/dox/stl.tag @@ -0,0 +1,28 @@ + + + + + std + + + T + memchr + cpp/string/byte/memchr + + (T... args) + + + + std::div_t + cpp/numeric/math/div + + T + quot + cpp/numeric/math/div + + + + + diff --git a/plugins/m/test/test_dox.py b/plugins/m/test/test_dox.py index e0f3f98a..b1ae534c 100644 --- a/plugins/m/test/test_dox.py +++ b/plugins/m/test/test_dox.py @@ -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')) -- 2.30.2