Below is a sample C++ header file formatted for use with doxygen, illustrating various doxygen features. /// /// \file Sample.h /// Sample class. This header does foobar. /// // // Tripple slash comments are included in the generated documentation, // while only double slash comments are not. // // Note that The file will not be included in the generated documentation // without the above \file marker, unless you specify in the doxygen // configuration that you want to include all files no matter what. ////////////////////////////////////////////////////////////////////////////// // // The following demonstrates how to group a class into a specific group // no matter which file it is in. This same structure can be used in any // file to add a class to the "exceptions" group. // /// \addtogroup exceptions /// @{ /// Thrown when bar goes foo. This documentation is directly above the /// class it describes, and doxygen will connect it automatically. class bad_bar : public exception { public bad_bar() {} const char *what() const; }; /// @} /// /// This class does something potentially useful. That first sentence /// will be used as a "one-liner" description, while the rest of the /// paragraph will be used in the larger description section. /// /// You can have as many paragraphs as you like, separated by spaces. /// /// You can even easily make bullet point lists, like: /// - item one /// - item two /// - item three with a really long long long long long long long /// description that needs to wrap a line /// /// Doxygen will format the above list appropriately. /// class foobar : public foobase { // doxygen will document the inheritance automatically protected: bool m_bSomeFlag; //< Use this format to document a variable or //< function after its declaration public: foobar(); ~foobar(); /// This will give a oneline description of the following member void do_foo(); bool do_foo(int, int*, ...); //< Or, use this method }; ------------------------------------------------------------------------------ And now for the source file: /// /// \file Sample.cc /// Sample class implementation. /// // note: the first 3 lines of the description will not be included below... // // do_foo // /// The first sentence gives the short description. Additional sentences /// give more info. /// /// Additional paragraphs for really complicated details. /// /// Even add bullet point lists: /// - one /// - two /// - three /// /// \note This will be hilighted in the documentation as a special note. /// /// You can use HTML in your descriptions as well. /// ///
/// Even give preformatted text ////// /// Describe the arguments explicitly. I use spaces to separate the param /// tag from the argument name, and tabs from the name to the description. /// Tabs also for secondary lines. /// /// \param[in] fmt Format for the variable arg function. You can /// describe this fully in a paragraph if you need. /// The [in] and [out] tags are optional /// \param[in,out] value Pointer to integer. The in,out indicates that /// the caller will pass data in and receive data /// out as well. [out] by itself is allowed too. /// \param ... Describe the variable argument list here. /// /// \returns bool /// - true - means success /// - false - some error occurred, use fooerror to find out what /// /// \exception std::logic_error /// Some explanation of what causes this exception. /// bool foobar::do_foo(int fmt, int *value, ...) { }