文档预处理器在Doxygen中定义 [英] Documenting preprocessor defines in Doxygen

查看:194
本文介绍了文档预处理器在Doxygen中定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在Doxygen中记录预处理器定义?我希望能够做一个变量或函数,但Doxygen输出看起来已失去的定义文档,并且不包含定义本身。



我试过下面的

  / **我的预处理器宏* / 
#define TEST_DEFINE x)(x * x)

  / ** @ def TEST_DEFINE 

我的预处理器宏。
* /
#define TEST_DEFINE(x)(x * x)

我也尝试把它们放在一个组(尝试defgroup,addtogroup和ingroup),而不是只在文件范围,但是没有影响(虽然组中的其他项目记录为预期)。



我浏览了各种Doxygen选项,但看不到任何能够启用(或阻止)定义文档的东西。

解决方案

是的,这是可能的。 Doxygen文档说:


要记录全局对象(函数,typedef,枚举,宏等),
,必须记录定义它们的文件。换句话说,
必须至少有一个



/ *! \file * /





/ ** @file * /



此文件中的行。


您可以使用 @defgroup @addtogroup @ ingroup 将相关项目放在同一个模块中,即使它们显示在单独的文件中(请参阅文档此处< a>)。下面是一个适用于我的最小示例(使用Doxygen 1.6.3):



Doxyfile

 #清空文件。 

Test.h

  / ** @file * / 

/ **我的预处理器宏* /
#define TEST_DEFINE * x)

/ **
* @defgroup TEST_GROUP测试组
*
* @ {
* /

/ **测试AAA文档。 * /
#define TEST_AAA(1)
/ **测试BBB文档。 * /
#define TEST_BBB(2)
/ **测试CCC文档。 * /
#define TEST_CCC(3)
/ ** @} * /

Foo.h

  / ** @file * / 

/ **
* @addtogroup TEST_GROUP
*
* @ {
* /

/ ** @brief My Class。 * /
class Foo {
public:
void method();
};

/ ** @} * /

Bar.h

  / ** @file * / 

/ **
* @ingroup TEST_GROUP
*我的函数。
* /
void Bar();

在这种情况下,会出现 TEST_DEFINE 在HTML输出中的文件标签下的 Test.h 条目中, TEST_AAA 模组标签中的测试组以及 Foo 和函数需要注意的一点是,如果你把文件名放在 @file 命令之后,例如:

  / ** @file Test.h * / 

那么这必须匹配文件的实际名称。如果没有,将不会生成文件中的项目的文档。



如果您不想添加 @file 命令,一个替代解决方案是设置 EXTRACT_ALL = YES 在您的Doxy文件中。



我希望这有助于!


Is it possible to document preprocessor defines in Doxygen? I expected to be able to do it just like a variable or function, however the Doxygen output appears to have "lost" the documentation for the define, and does not contain the define itself either.

I tried the following

/**My Preprocessor Macro.*/
#define TEST_DEFINE(x) (x*x)

and

/**@def TEST_DEFINE

   My Preprocessor Macro.
*/
#define TEST_DEFINE(x) (x*x)

I also tried putting them within a group (tried defgroup, addtogroup and ingroup) rather than just at the "file scope" however that had no effect either (although other items in the group were documented as intended).

I looked through the various Doxygen options, but couldn't see anything that would enable (or prevent) the documentation of defines.

解决方案

Yes, it is possible. The Doxygen documentation says:

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.

You can use @defgroup, @addtogroup, and @ingroup to put related items into the same module, even if they appear in separate files (see documentation here for details). Here's a minimal example that works for me (using 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();

In this case, the TEST_DEFINE documentation appears in the Test.h entry under the Files tab in the HTML output, and the TEST_AAA etc. definitions appear under Test Group in the Modules tab together with class Foo and function Bar.

One thing to note is that if you put the file name after the @file command, e.g:

/** @file Test.h */

then this must match the actual name of the file. If it doesn't, documentation for items in the file won't be generated.

An alternative solution, if you don't want to add @file commands, is to set EXTRACT_ALL = YES in your Doxyfile.

I hope this helps!

这篇关于文档预处理器在Doxygen中定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆