specify custom link title using the :rst:`:dox:`link title <link-target>``
syntax. If a symbol can't be found, a warning is printed to output and link
target is rendered in monospace font (or, if custom link title is specified,
-just the title is rendered, as normal text).
+just the title is rendered, as normal text). You can append ``#anchor`` to
+``link-target`` to link to anchors that are not present in the tag file (such
+as ``#details`` for the detailed docs or ``#pub-methods`` for jumping straight
+to a list of public member functions), the same works for query parameters
+starting with ``?``.
.. code-figure::
- Page link: :dox:`building-corrade`
- :dox:`Custom link title <testsuite>`
- :dox:`Link to documentation index page <corrade>`
+ - :dox:`Link to an anchor <Interconnect::Emitter#pub-methods>`
- Function link: :dox:`Utility::Directory::mkpath()`
- Class link: :dox:`Interconnect::Emitter`
- Page link: :dox:`building-corrade`
- :dox:`Custom link title <testsuite>`
- :dox:`Link to documentation index page <corrade>`
+ - :dox:`Link to an anchor <Interconnect::Emitter#pub-methods>`
`Abbreviations`_
================
from pelican import signals
import xml.etree.ElementTree as ET
import os
+import re
import logging
symbol_prefixes = ['']
tagfile_basenames = []
+# Modified from __init__ to add support for queries and hashes
+link_regexp = re.compile(r'(?P<title>.*) <(?P<link>[^?#]+)(?P<hash>[?#].+)?>')
+
+def parse_link(text):
+ link = utils.unescape(text)
+ m = link_regexp.match(link)
+ if m:
+ title, link, hash = m.group('title', 'link', 'hash')
+ if not hash: hash = '' # it's None otherwise
+ else:
+ title, hash = '', ''
+
+ return title, link, hash
+
def init(pelicanobj):
global symbol_mapping, symbol_prefixes, tagfile_basenames
symbol_mapping[section.text] = (section.attrib.get('title', ''), link + '#' + section.text)
def dox(name, rawtext, text, lineno, inliner: Inliner, options={}, content=[]):
- title, target = parse_link(text)
+ title, target, hash = parse_link(text)
# Try linking to the whole docs first
for basename, url in tagfile_basenames:
logger.warning("Link to main page `{}` requires a title".format(target))
title = target
- node = nodes.reference(rawtext, title, refuri=url, **options)
+ node = nodes.reference(rawtext, title, refuri=url + hash, **options)
return [node], []
for prefix in symbol_prefixes:
logger.warning("Doxygen anchor `{}` has no title, using its ID as link title".format(target))
use_title = target
- node = nodes.reference(rawtext, use_title, refuri=url, **options)
+ node = nodes.reference(rawtext, use_title, refuri=url + hash, **options)
return [node], []
# TODO: print file and line
<li><a href="http://doc.magnum.graphics/corrade/corrade-cmake.html">Page link with custom title</a></li>
<li><a href="http://doc.magnum.graphics/corrade/">Link to index page</a></li>
<li><a href="http://doc.magnum.graphics/corrade/classCorrade_1_1TestSuite_1_1Tester.html#TestSuite-Tester-command-line">Link to class documentation section</a></li>
+<li><a href="http://doc.magnum.graphics/corrade/#search">Link to index page with hash after</a></li>
+<li><a href="http://doc.magnum.graphics/corrade/corrade-cmake.html#search">Link to page with hash after</a></li>
+<li><a href="http://doc.magnum.graphics/corrade/namespaceCorrade_1_1Utility_1_1Directory.html?q=hello#search">Link to class with query and hash after</a></li>
</ul>
<p>These should produce warnings:</p>
<ul>
- :dox:`Page link with custom title <corrade-cmake>`
- :dox:`Link to index page <corrade>`
- :dox:`Link to class documentation section <TestSuite-Tester-command-line>`
+- :dox:`Link to index page with hash after <corrade#search>`
+- :dox:`Link to page with hash after <corrade-cmake#search>`
+- :dox:`Link to class with query and hash after <Utility::Directory?q=hello#search>`
These should produce warnings: