Baptiste Wicht
Baptiste Wicht

Reputation: 7663

How to document enumeration values with same name with 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 ?

Upvotes: 9

Views: 1822

Answers (1)

Pubby
Pubby

Reputation: 53067

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.

Upvotes: 2

Related Questions