Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to document enumeration values with same name with Doxygen?

Tags:

c++

c++11

doxygen

I'm trying to document two class enumerations containing some similar values with Doxygen. But that generates duplicates text for each field with the same name.

Here are my two enumerations :

/*!
 * \enum OperandType
 * \brief A type of operand. Represents the location of the operand.
 */
enum class OperandType : unsigned int {
    IMMEDIATE,          /**< An immediate operand */
    REGISTER,           /**< An operand in a register */
    STACK,              /**< An operand on the stack */
    GLOBAL              /**< A global operand */
};
/*!
 * \enum PositionType
 * \brief A type of position for a variable
 */
enum class PositionType : unsigned int {
    STACK,          /**< A variable on the stack  */
    PARAMETER,      /**< A parameter */
    GLOBAL,         /**< A global variable */
    CONST           /**< A const variable.*/
};

The description for the STACK member of each enumeration is the concatenation of both descriptions and there is the same problem for GLOBAL.

The description of STACK is :

A variable on the stack

An operand on the stack

Is there a way to document each of them specifically ?

like image 264
Baptiste Wicht Avatar asked Nov 30 '11 22:11

Baptiste Wicht


People also ask

Can different enumeration may have same name?

1. Two enum names can have same value. For example, in the following C program both 'Failed' and 'Freezed' have same value 0.

How to comment code for Doxygen?

doxygen Getting started with doxygen Commenting your code//! //! ... text ... //! Note the 2 slashes to end the normal comment block and start a special comment block.

How does ENUM work in Ruby?

In Ruby on Rails, an enum is an attribute where the values map to integers in the database and can be queried by name. For example, we could define an enum for the status attribute, where the possible values are pending , active , or archived . Ruby on Rails added support for enums in Rails 4.1.

What is Doxygen documentation?

Doxygen (/ˈdɒksidʒən/ DOK-see-jən) is a documentation generator and static analysis tool for software source trees. When used as a documentation generator, Doxygen extracts information from specially-formatted comments within the code.


1 Answers

Workaround is to put it in a namespace and using to bring it out.

/*!
 * enum class
*/
namespace enum_class {
  /*!
   * \enum OperandType
   * \brief A type of operand. Represents the location of the operand.
   * Ok
   */
  enum class OperandType : unsigned int {
      IMMEDIATE,          /**< An immediate operand */
          REGISTER,           /**< An operand in a register */
      STACK,              /**< An operand on the stack */
      GLOBAL              /**< A global operand */
  };
}
using enum_class::OperandType;
/*!
 * \enum PositionType
 * \brief A type of position for a variable
 */
enum class PositionType : unsigned int {
    STACK,          /**< A variable on the stack  */
    PARAMETER,      /**< A parameter */
    GLOBAL,         /**< A global variable */
    CONST           /**< A const variable.*/
};

You can put PositionType in a separate namespace (enumeration) if you don't like the separation.

like image 79
Pubby Avatar answered Oct 05 '22 02:10

Pubby