如何使用Doxygen记录具有相同名称的枚举值?

9

我想用Doxygen记录两个包含一些相似值的类枚举。但是这会为每个具有相同名称的字段生成重复文本。

以下是我的两个枚举:

/*!
 * \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.*/
};

每个枚举的STACK成员的描述是两个描述的连接,GLOBAL也存在同样的问题。
STACK的描述如下:

堆栈上的变量

堆栈上的操作数

是否有一种特定的方式来记录它们?

4
Doxygen对C++11的支持相当糟糕。 - Pubby
1
如果将其中一个枚举放入命名空间中,然后将该枚举导入到父命名空间中,它是否有效?我想象中应该有一种更好的方法,但我不太了解doxygen。希望它的C++11支持能够快速提高。 - bames53
1个回答

2

解决方法是将其放在命名空间中,然后使用 using 将其引出。

/*!
 * 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.*/
};

如果您不喜欢这种分离方式,可以将PositionType放在一个单独的命名空间(枚举)中。


它可以工作,但枚举被记录在 enum_class 下,而不是我的命名空间下。我认为这不是理想的,因为使用此枚举的人将在根命名空间中搜索文档。有没有办法告诉 Doxygen 生成一个 using 的文档? - Baptiste Wicht

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接