【问题标题】:How to document enumeration values with same name with Doxygen?如何用 Doxygen 记录同名的枚举值?
【发布时间】:2011-11-30 22:44:10
【问题描述】:

我正在尝试使用 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的描述是:

栈上的变量

栈上的操作数

有没有办法专门记录它们中的每一个?

【问题讨论】:

  • Doxygen 对 C++11 的支持很差。
  • 如果将其中一个枚举放入命名空间,然后将枚举导入父命名空间,它是否有效?我想有一种不那么丑陋的方式,但我不太了解 doxygen。希望它对 C++11 的支持能够快速改进

标签: c++ c++11 doxygen


【解决方案1】:

解决方法是将其放在命名空间中,然后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 放在单独的命名空间 (enumeration) 中。

【讨论】:

  • 它可以工作,但是枚举记录在 enum_class 下而不是我的命名空间下。我认为这并不理想,因为使用此枚举的人将在根命名空间中搜索文档。有没有办法告诉 Doxygen 为 using 生成文档?
猜你喜欢
  • 2012-11-24
  • 2014-10-07
  • 2010-10-07
  • 2014-04-10
  • 2014-09-03
  • 2014-03-02
  • 1970-01-01
  • 2012-08-15
  • 2020-09-19
相关资源
最近更新 更多