chiark / gitweb /
m.dox: render the link as code only if there's no custom title.
authorVladimír Vondruš <mosra@centrum.cz>
Mon, 1 Jan 2018 20:08:23 +0000 (21:08 +0100)
committerVladimír Vondruš <mosra@centrum.cz>
Mon, 1 Jan 2018 20:37:15 +0000 (21:37 +0100)
And properly test this case.

pelican-plugins/m/dox.py
pelican-plugins/m/test/dox/page.html
pelican-plugins/m/test/dox/page.rst

index 73a82283e992cd177763c7853ad2d1e1e1f7d27f..083ddb0297104de0f52768e004eb6dd6519b9004 100644 (file)
@@ -117,8 +117,12 @@ def dox(name, rawtext, text, lineno, inliner: Inliner, options={}, content=[]):
     #msg = inliner.reporter.warning(
         #'Doxygen symbol %s not found' % target, line=lineno)
     #prb = inliner.problematic(rawtext, rawtext, msg)
-    logger.warning('Doxygen symbol `%s` not found, rendering as monospace' % target)
-    node = nodes.literal(rawtext, title if title else target, **options)
+    if title:
+        logger.warning("Doxygen symbol `{}` not found, rendering just link title".format(target))
+        node = nodes.inline(rawtext, title, **options)
+    else:
+        logger.warning("Doxygen symbol `{}` not found, rendering as monospace".format(target))
+        node = nodes.literal(rawtext, target, **options)
     return [node], []
 
 def register():
index f691e5d01f17801e65ff2b5f78de6ec59160a391..a30bf77a5ae35d92c6f212302997addd592f9404 100644 (file)
@@ -32,6 +32,8 @@
 </ul>
 <p>These should produce warnings:</p>
 <ul>
+<li>Link to nonexistent name will be rendered as code: <code>nonExistent()</code></li>
+<li><span>Link to nonexistent name with custom title will be just text</span></li>
 <li>Link to a section that doesn't have a title will keep the ID (this <em>may</em>
 break on tagfile update, watch out): <a href="http://doc.magnum.graphics/corrade/corrade-cmake.html#corrade-cmake-add-test">corrade-cmake-add-test</a></li>
 </ul>
index c27f2f2becf1ea4034f8ff7de71a324df5720f4e..74b32710012da70485347455a78e901ef3605b5c 100644 (file)
@@ -9,5 +9,7 @@ m.dox
 
 These should produce warnings:
 
+-   Link to nonexistent name will be rendered as code: :dox:`nonExistent()`
+-   :dox:`Link to nonexistent name with custom title will be just text <nonExistent()>`
 -   Link to a section that doesn't have a title will keep the ID (this *may*
     break on tagfile update, watch out): :dox:`corrade-cmake-add-test`