9

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 ?

2
  • 4
    Doxygen has pretty bad support for C++11. Commented Nov 30, 2011 at 22:47
  • 1
    Does it work if you put one of the enums into a namespace and then afterwards import the enum into the parent namespace? I'd imagine there's a less ugly way but I don't know doxygen well. Hopefully its C++11 support improves quickly Commented Nov 30, 2011 at 22:52

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

1 Comment

It works but then the enumeration is documented under enum_class and not under my namespace. I think this is not ideal as the person using this enum will search the documentation in the root namespace. Is there a way to tell Doxygen to generate documentation for a using ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.