From: Vladimír Vondruš Date: Mon, 1 Jan 2018 20:08:23 +0000 (+0100) Subject: m.dox: render the link as code only if there's no custom title. X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~cjwatson/git?a=commitdiff_plain;h=19004b3ed92ec6c9efc278753786f5a604096b6f;p=blog.git m.dox: render the link as code only if there's no custom title. And properly test this case. --- diff --git a/pelican-plugins/m/dox.py b/pelican-plugins/m/dox.py index 73a82283..083ddb02 100644 --- a/pelican-plugins/m/dox.py +++ b/pelican-plugins/m/dox.py @@ -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(): diff --git a/pelican-plugins/m/test/dox/page.html b/pelican-plugins/m/test/dox/page.html index f691e5d0..a30bf77a 100644 --- a/pelican-plugins/m/test/dox/page.html +++ b/pelican-plugins/m/test/dox/page.html @@ -32,6 +32,8 @@

These should produce warnings:

diff --git a/pelican-plugins/m/test/dox/page.rst b/pelican-plugins/m/test/dox/page.rst index c27f2f2b..74b32710 100644 --- a/pelican-plugins/m/test/dox/page.rst +++ b/pelican-plugins/m/test/dox/page.rst @@ -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 ` - 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`