【问题标题】:Document enum class values using Doxygen without enabling EXTRACT_ALL使用 Doxygen 记录枚举类值而不启用 EXTRACT_ALL
【发布时间】:2020-09-19 00:49:51
【问题描述】:

如果没有设置EXTRACT_ALL,我无法显示枚举类值的文档。用于保留、截断和追加的 cmets 不存在。枚举本身已记录在案。如果我启用EXTRACT_ALL,我会得到一个列表。

我的代码是:

namespace grimoire
{

...

/// @brief Behaviour of function open_for_write for already existing files.
/// @see open_for_write()
enum class OpenMode
{
    preserve = std::ofstream::out,   /// Already existing file aren't opened.
    truncate = std::ofstream::trunc, /// Discard existing contents.
    append   = std::ofstream::app    /// Append to existing contents.
};

...

}

我正在使用 CMake 运行 Doxygen:

#set(DOXYGEN_EXTRACT_ALL YES)
doxygen_add_docs(
    docs
    "${CMAKE_CURRENT_SOURCE_DIR}/include/grimoire"
    "${CMAKE_CURRENT_SOURCE_DIR}/src")

编辑:

它甚至不适用于经典枚举并且没有显式值。好像和我的设置有关。

已解决:

我必须在封闭的命名空间中添加注释。 Doxygen 提取了枚举本身以及该命名空间内的函数和类等其他内容,但不提取枚举条目。

【问题讨论】:

  • Doxygen 并不完全理解 C++。它有时会出错。

标签: c++ cmake doxygen enum-class


【解决方案1】:

Doxygen 并不总是获取枚举,这可以通过使用 \file 命令来克服。 此外,您在 其定义之后记录枚举值,这意味着您不应使用 /// 而应使用 ///<

所以有限的例子看起来像:

/// \file


/// @brief Behavior of function open_for_write for already existing files.
/// @see open_for_write()
enum class OpenMode
{
    preserve = std::ofstream::out,   ///< Already existing file aren't opened.
    truncate = std::ofstream::trunc, ///< Discard existing contents.
    append   = std::ofstream::app    ///< Append to existing contents.
};

编辑: 根据 OP 的回答,给定的解决方案并不完整,因为原始问题嵌入在命名空间中。为了能够在这种情况下显示枚举,添加\file 是不够的,但还需要将文件命名空间。所以一个更完整的例子:

/// \file

/// The namespace documentation
namespace NS
{
  /// @brief Behavior of function open_for_write for already existing files.
  /// @see open_for_write()
  enum class OpenMode
  {
      preserve = std::ofstream::out,   ///< Already existing file aren't opened.
      truncate = std::ofstream::trunc, ///< Discard existing contents.
      append   = std::ofstream::app    ///< Append to existing contents.
  };
};

【讨论】:

  • @file 和 /// 仍然没有运气
猜你喜欢
  • 2014-10-07
  • 2012-11-24
  • 2010-10-07
  • 2014-09-03
  • 2014-03-02
  • 2014-04-10
  • 1970-01-01
  • 1970-01-01
  • 2013-04-20
相关资源
最近更新 更多