[Documentation] [TitleIndex] [WordIndex


See also: rosdoc_lite, Epydoc, Sphinx

Doxygen is a tool for auto-generating API documentation, though you can also use it to generate documentation separate from an API. The main advantage of Doxygen is that you can write documentation directly within the comments of your source code. Doxygen searches for source code in your tree and generates API documentation for it.

You don't need to configure and run Doxygen manually in order to generate documentation for your ROS package. Instead, we recommend that you use the rosdoc_lite tool, which provides common templating and other features.

With ROS packages, we generally use Doxygen to document C++-based code. For Python we generally use Epydoc or Sphinx.

NOTE: this page is not a comprehensive guide to Doxygen. For actual documentation on how to use the Doxygen documentation tool, please see the official Doxygen site.

Adding documentation to your code

You can use any Doxygen markup in your code. The first thing you'll probably want to do is use the \mainpage tag. There should only be one mainpage tag in your package, so we usually recommend creating a top-level file, e.g. mainpage.dox, with a \mainpage tag. To make things easier, we have created a default template in the rosdoc package, which you can find at rosdoc/templates/mainpage.dox.template. Also, if you use the roscreate-pkg tool to create your package, a mainpage.dox will be generated for you.

NOTE: you have to use C++ comment syntax in this file, e.g., :



\htmlinclude manifest.html

\b nav_view is....


The \htmlinclude line inputs a nicely formatted version of the package's manifest.xml file.

Doxygen's main strength is that you can include documentation inline with your code. Here is an example geared toward a class that is likely compiled into a library:

//* A name class
* The basic class description, it does:
* 1. blah
* 2. blah ....
class NameOneTwo
    * \brief This description shows up at the top of the doxygen so you don't have to scroll.
    * This description is displayed lower in the doxygen as an extended description along with
    * the above brief description.
    * \param junk       This is a cool junk varible
    int MethodOne( int junk);

    * \brief This description shows up at the top of the doxygen so you don't have to scroll.
    * This description is displayed lower in the doxygen as an extended description along with
    * the above brief description.
    int MethodTwo();

    int var_abc;                /**< A variable (i.e. it does something special). */
    int error_number;     /**< A variable that can be confused with the other variable. */
    string* name;           /**< A variable that is the coolest. */

The \todo tag

Doxygen provides a \todo tag, that can be used in any Doxygen-style comment block, e.g.:

/** @todo Make the value externally configurable */
double distance = 1.0;

Doxygen collects these tags into a "related page," providing a nice reference for remaining work. This is better than using //TODO or //FIXME or whatever other comments you might normally use, because it makes the todo-ness externally visible.

Please use the \todo tag wherever applicable.

rosdoc: Default Doxygen Settings

rosdoc comes with default settings that generally work well with packages in ROS. The most important is FILE_PATTERNS: these are the files that Doxygen will look inside of for documentation. By default, this is:

You can "roscd rosdoc" and look at the templates/doxy.template to see the many of the default settings used with Doxygen. For example, IMAGE_PATH is set to the root of the project.

For more information on customizing these settings, please see rosdoc_lite.

Embedding Markdown Pages

If you use markdown a lot, it can be more convenient to create non-api pages of documentation for your package using markdown syntax instead of the regular doxygen syntax.



- builder: doxygen
  file_patterns: '*.cpp *.hpp *.dox *.md'

my_catkin_package$ rosdoc_lite .


Markdown Extensions

There are a few doxygen extensions that go beyond regular markdown support, see the official document in the Markdown Extensions section. Notably:

With this, you can link to other markdown pages by referencing the labels for their pages/sections. e.g. other.md

Other {#otherpage}

# Other # {#OtherSection}

More Foo

You should link to this by using the doxygen style reference:

[Other](@ref otherpage)

2018-03-17 12:16