是否可以在 Doxygen 中记录预处理器定义?我希望能够像变量或函数一样执行此操作,但是 Doxygen 输出似乎“丢失”了定义的文档,并且也不包含定义本身。
我尝试了以下
/**My Preprocessor Macro.*/
#define TEST_DEFINE(x) (x*x)
和
/**@def TEST_DEFINE
My Preprocessor Macro.
*/
#define TEST_DEFINE(x) (x*x)
我还尝试将它们放在一个组中(尝试了 defgroup、addtogroup 和 ingroup),而不是仅仅放在“文件范围”,但这也没有效果(尽管该组中的其他项目已按预期记录)。
我查看了各种 Doxygen 选项,但没有看到任何可以启用(或阻止)定义文档的内容。
最佳答案
是的,这是可能的。 Doxygen documentation说:
To document global objects (functions, typedefs, enum, macros, etc), you must document the file in which they are defined. In other words, there must at least be a
/*! \file */
or a
/** @file */
line in this file.
您可以使用 @defgroup
、@addtogroup
和 @ingroup
将相关项放在同一个模块中,即使它们出现在单独的文件(详见文档 here)。这是一个适用于我的最小示例(使用 Doxygen 1.6.3):
Doxyfile:
# Empty file.
Test.h:
/** @file */
/**My Preprocessor Macro.*/
#define TEST_DEFINE(x) (x*x)
/**
* @defgroup TEST_GROUP Test Group
*
* @{
*/
/** Test AAA documentation. */
#define TEST_AAA (1)
/** Test BBB documentation. */
#define TEST_BBB (2)
/** Test CCC documentation. */
#define TEST_CCC (3)
/** @} */
Foo.h:
/** @file */
/**
* @addtogroup TEST_GROUP
*
* @{
*/
/** @brief My Class. */
class Foo {
public:
void method();
};
/** @} */
Bar.h:
/** @file */
/**
* @ingroup TEST_GROUP
* My Function.
*/
void Bar();
在这种情况下,TEST_DEFINE
文档出现在 HTML 输出的 Files 选项卡下的 Test.h 条目中,并且 TEST_AAA
等定义与类 Foo
和函数 Bar< 一起出现在 Modules 选项卡的 Test Group 下
。
需要注意的一点是,如果你把文件名放在 @file
命令之后,例如:
/** @file Test.h */
那么这必须与文件的实际名称相匹配。如果没有,则不会生成文件中项目的文档。
如果您不想添加 @file
命令,另一种解决方案是在 Doxyfile 中设置 EXTRACT_ALL = YES
。
我希望这会有所帮助!
关于c++ - 在 Doxygen 中记录预处理器定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2356120/