Search code examples
c++doxygencode-documentation

Can I make doxygen resolve @ref's to C++ standard library functions?


I sometimes want to refer, in my doxygen comments, to standard library constructs. I can do this with a HTML <a> element - but that's a lot of text to paste. I would much rather be able to write simply {@ref std::string}, and have doxygen know it needs to link to the cppreference.org page for std::string.

I was thinking perhaps this could be possible if someone were to generate a doxygen tags file for the standard library (and even that might not work if tags file don't support arbitrary URLs). So, is there another way to do it?


Solution

  • You should have a Doxygen tag file and corresponding offline or online html files. So you can declare it in the Doxygen config file with this format:

    TAGFILES = "/location/of/tagFile=http://onlineUrl Or /location/of/OfflineHtml"
    

    To download these files, i found two below resources:

    Cppreference

    I recommend this way. because of complete documentation of it.

    Online link

    1. Download web tag file.
    2. Set below in config file:

      TAGFILES += "location/of/cppreference-doxygen-web.tag.xml=http://en.cppreference.com/w/"
      

    Offline link

    1. Download html book that is offline copy of the website.
    2. Set below in config file:

      TAGFILES += "location/of/cppreference-doxygen-local.tag.xml=/location/of/html_book_*\reference\en"
      

    More


    GNU project

    Online link

    1. Download a tag file for the latest version.
    2. Set below in config file:

      TAGFILES = "/location/of/libstdc++.tag = http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen"
      

    Offline link

    1. Download GCC 7.1 Standard C++ Library Reference Manual in HTML. other versions found here.
    2. Set below in config file:

      TAGFILES = "/location/of/libstdc++.tag = /location/of/libstdc++-api-html"
      

    More