使用 Doxygen 记录枚举类值,而不启用EXTRACT_ALL
Document enum class values using Doxygen without enabling EXTRACT_ALL
如果不设置EXTRACT_ALL
,我无法显示枚举类值的文档。保留、截断和追加的注释不存在。枚举本身是有文档记录的。如果我启用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 并不总是拾取枚举,这可以通过使用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.
};
};
相关文章:
- OpenGL在启用深度测试时不会丢弃我的碎片
- 视觉工作室 2017;启用 /permissive 时,类型 "const wchar_t *" 的参数与类型 "PWSTR" 的参数不兼容
- 使用 Doxygen 记录枚举类值,而不启用EXTRACT_ALL
- 如果作为参数传递的函子不带参数,则启用模板
- 我什么时候不希望在Visual Studio中启用“Control Flow Guard Microsoft
- 我如何在不启用例外的情况下构建Boost 1.70.0
- 即使启用了 Wextra,gcc 也不会给出将无符号整数< 0 进行比较的警告
- QSocketNotifier:不能从另一个线程启用或禁用套接字通知程序
- 为什么 g++ 不发出这个与构造函数相关的 noexcept 启用"-fpic"的警告?
- 不存在的标识符在非启用函数模板中用作默认参数
- 我如何在C 中不启用对象
- 每当表达式不确定时,启用C 中的函数模板
- 为什么叮当不能启用所有消毒剂?
- C++仅在不存在时才启用的功能
- 为什么g++在这里不启用RVO
- 如何在Qt5中启用不推荐使用的函数
- 如何在Boost程序选项中启用其他选项而不使用变量
- clang中是否有一组已知的' c++11 '特性默认启用而不需要' -std=c++11 ' ?
- 当启用了_GLIBCXX_DEBUG时,Stringstream不能使用double
- 不可能启用/禁用带有sfinae的typedef.工作区