【问题标题】:Documenting enum class values with doxygen使用 doxygen 记录枚举类值
【发布时间】:2014-10-07 18:35:23
【问题描述】:

在我的项目中,我经常使用枚举类,并且我使用 doxygen 作为文档系统。 当在同一个文件中声明多个枚举类并且它们具有相同的成员时,我发现很难生成枚举类的文档。 例如,以下代码未在最终 HTML 输出中为枚举类 IMAGE_REPORTING 生成正确的文档:

namespace mapper
{
  /* CONNECTION RELATED */
  /** @enum mapper::SECURE_WEBSOCKET
   *  \author Michele Adduci
   *  \ingroup Core
   *  @brief is a strongly typed enum class representing the status of websocket connection
   *  @var mapper::SECURE_WEBSOCKET::DISABLED
   *  is coded as std::int8_t of value 0
   *  @var mapper::SECURE_WEBSOCKET::ENABLED
   *  is coded as std::int8_t of value 1
   */
  enum class SECURE_WEBSOCKET : std::int8_t {DISABLED = 0, ENABLED = 1};

  /* IMAGE RELATED */
  /** @enum mapper::IMAGE_REPORTING
   *  \author Michele Adduci
   *  \ingroup Core
   *  @brief is a strongly typed enum class representing the status of image reporting
   *  @var mapper::IMAGE_REPORTING::DISABLED
   *  is coded as std::int8_t of value 0
   *  @var mapper::IMAGE_REPORTING::ENABLED
   *  is coded as std::int8_t of value 1
 */
  enum class IMAGE_REPORTING : std::int8_t {DISABLED = 0, ENABLED = 1};
}

输出:

知道是什么问题吗?

【问题讨论】:

    标签: c++ doxygen


    【解决方案1】:

    我在全局枚举方面遇到了类似的问题。一些头文件为枚举生成了一个链接,而其他头文件没有。您必须明确记录该文件。

    这是文档中此页面的摘录。 http://www.doxygen.nl/manual/docblocks.html#memberdoc

    记录全局 C 函数、typedef、枚举或预处理器 定义你必须首先记录包含它的文件(通常 这将是一个头文件,因为该文件包含信息 导出到其他源文件)。

    注意 让我们重复一遍,因为它经常被忽略:要记录全局对象(函数、typedef、枚举、宏等),您必须 记录定义它们的文件。换句话说,有 至少必须是一个

    /*! \file */ 
    
    or a
    
    /** @file */ 
    
    line in this file.
    

    【讨论】:

    • mmm...这听起来像是一个新的添加...早在 2014 年它不存在,但感谢报告它
    【解决方案2】:

    您可以使用对我有用的内联文档:

    /** @enum mapper::IMAGE_REPORTING
     *  \author Michele Adduci
     *  \ingroup Core
     *  @brief is a strongly typed enum class representing the status of image reporting
     */
    enum class IMAGE_REPORTING : std::int8_t {
      DISABLED = 0, /**< is coded as std::int8_t of value 0 */
      ENABLED = 1   /**< is coded as std::int8_t of value 1 */
    }
    

    另一个类似。

    【讨论】:

    • 注意你也可以去掉上面例子中的@enum命令,它是多余的,只是输入错误的来源。
    猜你喜欢
    • 2012-11-24
    • 2010-10-07
    • 2020-09-19
    • 2014-09-03
    • 2014-03-02
    • 2014-04-10
    • 1970-01-01
    • 1970-01-01
    • 2012-11-18
    相关资源
    最近更新 更多