Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Documenting enum values with doxygen

Given:

namespace Foo {     class Foo {     public:         /// Foo enum, possible ways to foo         enum class Foo {             /// Foo it with an A             A,             /// Foo it with a B             B,             /// Foo it with a C             C         }     } } 

And the default Doxyfile made with doxygen -g, I get this:

generated documentation

How can I get the enum values documented? I tried putting the comment before/after the member, using ///<, etc, to no avail. Might this just be a bug in doxygen? The examples in the docs work. (Clicking on the name of the enum doesn't bring me anywhere)

like image 585
Corey Richardson Avatar asked Dec 06 '12 20:12

Corey Richardson


People also ask

How do I document an enum?

In order to document an enum in Swagger, we need to declare the models using annotation @ApiModel. In this example, we created an enum Role with four possible values – Engineer, Clerk, Driver, and Janitor. As we need to document this enum, we'll add @ApiModel to the enum Role.

What is @brief in doxygen?

Putting the command @brief will generate a short description of the function when you generate the doxygen documentation. That short description can be extended if you want. Follow this answer to receive notifications.

How do you make doxygen comments?

To create a Doxygen comment from scratch: Type one of the following symbols: /// , //! , /** or /*! and press Enter .


2 Answers

With Doxygen 1.8.2, both the following work for me:

Using ///

/// This is an enum class enum class fooenum {     FOO, ///< this is foo     BAR, ///< this is bar }; 

Using /*! ... */

/*! This is an enum class */ enum class fooenum {     FOO, /*!< this is foo */     BAR, /*!< this is bar */ }; 

Brief DescriptionDetailed Description

The doxygen changelog says that enum class is supported in Doxygen 1.8.2, so I suspect there may be some minor syntax issue in your commands. Could you please compare your commands with the above two snippets?

New features

Added support for C++11:

strongly typed enums, e.g.: enum class E 
like image 73
Masked Man Avatar answered Sep 22 '22 18:09

Masked Man


Note that I personally hate to have header files that go at length (because documenting means writing at least 2 or 3 lines of documentation, not one word so I generally don't have enough with the brief) so I prefer to document in the .cpp file.

To do that you use the \var feature of Doxygen.

So the header comes bare:

namespace Foo {     class Foo {     public:         enum class Foo {             A,             B,             C         };     }; } 

And the .cpp file has:

namespace Foo {  /** \enum Foo::Foo  * \brief Foo enum, possible ways to foo  *  * All the necessary details about this enumeration.  */  /** \var Foo::A  * \brief Foo it with an A  *  * When you use A... etc.  */  /** \var Foo::B  * \brief Foo it with a B  *  * When you use B... etc.  */  /** \var Foo::C  * \brief Foo it with a C  *  * When you use C... etc.  */  } 

That way, I can really document at length which happens often to me.

like image 21
Alexis Wilke Avatar answered Sep 26 '22 18:09

Alexis Wilke