Doxylink is a Sphinx extension to link to external Doxygen API documentation.
It allows you to specify C++ symbols and it will convert them into links to the HTML page of their Doxygen documentation.
You use Doxylink like:
:polyvox:`PolyVox::Volume`
You use :qtogre:`QtOgre::Log` to log events for the user.
:polyvox:`PolyVox::Array::operator[]`
Where polyvox and qtogre roles are defined by the doxylink configuration value.
Like any interpreted text role in Sphinx, if you want to display different text to what you searched for, you can include some angle brackets <...>. In this case, the text inside the angle brackets will be used to match up with Doxygen and the part in front will be displayed to the user:
:polyvox:`Array <PolyVox::Array>`.
:polyvox:`tidyUpMemory <tidyUpMemory(int)>` will reduce memory usage.
Note
In C++, it is common that classes and functions will be templated and so will have angle brackets themselves. For example, the C++ class:
PolyVox::Array<0,ElementType>
would be naively linked to with Doxylink with:
:polyvox:`PolyVox::Array<0,ElementType>`
but that would result in Sphinx parsing it as you wanting to search for 0,ElementType and display PolyVox::Array as the text to the user. To avoid this misparsing you must escape the opening < by prepending it with a \:
:polyvox:`PolyVox::Array\<0,ElementType>`
If you want to use templated symbols inside the angle brackets like:
:polyvox:`Array <PolyVox::Array<0,ElementType>>`
then that will work without having to escape anything.
For non-functions (i.e. namespaces, classes, enums, variables) you simply pass in the name of the symbol. If you pass in a partial symbol, e.g. `Volume` when you have a symbol in C++ called PolyVox::Utils::Volume then it would be able to match it as long as there is no ambiguity (e.g. with another symbol called PolyVox::Old::Volume). If there is ambiguity then simply enter the fully qualified name like:
:polyvox:`PolyVox::Utils::Volume` or :polyvox:`PolyVox::Utils::Volume <Volume>`
For functions there is more to be considered due to C++’s ability to overload a function with multiple signatures. If you want to link to a function and either that function is not overloaded or you don’t care which version of it you link to, you can simply give the name of the function with no parentheses:
:polyvox:`PolyVox::Volume::getVoxelAt`
Depending on whether you have set the add_function_parentheses configuration value, Doxylink will automatically add on parentheses to that it will be printed as PolyVox::Volume::getVoxelAt().
If you want to link to a specific version of the function, you must provide the correct signature. For a requested signature to match on in the tag file, it must exactly match a number of features:
The argument list is not whitespace sensitive (any more than C++ is anyway) and the names of the arguments and their default values are ignored so the following are all considered equivalent:
:myapi:`foo( const QString & text, bool recalc, bool redraw = true )`
:myapi:`foo(const QString &foo, bool recalc, bool redraw = true )`
:myapi:`foo( const QString& text, bool recalc, bool redraw )`
:myapi:`foo(const QString&,bool,bool)`
When making a match, Doxylink splits up the requested string into the function symbol and the argument list. If it finds a match for the function symbol part but not for the argument list then it will return a link to any one of the function versions.
You can also link directly to a header or source file by giving the name of the file:
:myapi:`main.cpp`
:myapi:`MainWindow.h`
When generating your Doxygen documentation, you need to instruct it to create a ‘tag’ file. This is an XML file which contains the mapping between symbols and HTML files. To make Doxygen create this file ensure that you have a line like:
GENERATE_TAGFILE = PolyVox.tag
in your Doxyfile.
The environment is set up with a dictionary mapping the interpereted text role to a tuple of tag file and prefix:
doxylink = {
'polyvox' : ('/home/matt/PolyVox.tag', '/home/matt/PolyVox/html/'),
'qtogre' : ('/home/matt/QtOgre.tag', '/home/matt/QtOgre/html/'),
}
A boolean that decides whether parentheses are appended to function and method role text. Default is True.
If you find any errors, bugs, crashes etc. then please let me know. You can contact me at matt@milliams.com. If there is a crash please include the backtrace and log returned by Sphinx. If you have a bug, particularly with Doxylink not being able to parse a function, please send the tag file so tat I can reproduce and fix it.
requires: | Python 2.5 |
---|
copyright: | Copyright 2011 by Matt Williams |
---|---|
license: | BSD, see LICENSE for details. |