如何用Doxygen记录宏生成的类? [英] How to document macro-generated classes with Doxygen?
问题描述
我使用宏以下列方式生成类:
I use macros to generate classes in the following way:
generator.h:
generator.h:
class CLASS_NAME : public parent
{
//generate variables with names given by CLASS_VARIABLES using complicated
//Boost.Preprocessor stuff.
};
#undef CLASS_NAME
#undef CLASS_VARIABLES
myclass.h :
myclass.h:
#define CLASS_NAME MyClass
#define CLASS_VARIABLES (a, b, c, x, y, z)
#include "generator.h"
实际的类更复杂,使用各种Boost。预处理器宏。有没有办法通过添加注释到generator.h自动文档生成的类与Doxygen,或者替代生成一个示例类文档?我已经尝试启用ENABLE_PREPROCESSING和MACRO_EXPANSION,但这似乎不足。
The actual class is more complicated and uses various Boost.Preprocessor macros. Is there a way to automatically document the generated classes with Doxygen by adding comments to generator.h, or alternatively to generate an example class with documentation? I have tried enabling ENABLE_PREPROCESSING and MACRO_EXPANSION, but this does not seem to suffice.
推荐答案
它不工作。 Doxygen预处理器并不真正执行完全文件包含(它只包含宏定义的包含文件;否则ENABLE_PREPROCESSING指令将是完全无用的!)。所以 #includegenerator.h
没有效果。
It won't work. The Doxygen preprocessor doesn't really perform full blown file inclusion (it only looks in the included files for macro definitions; otherwise, the ENABLE_PREPROCESSING directive would be totally useless!). So the #include "generator.h"
has no effect.
如果您使用所包含文件的内容物理替换 #include
指令,则它会正常工作。 (不是很有用,我知道)。
If you physically replace the #include
directive with the content of the included file, it will work. (Not very useful, I know).
另一种方法是修改这样的文件:
Another way to do this is to modify your files like this:
generator.h:
generator.h:
#define DEFCLASS class CLASS_NAME : public parent \
{ \
... whatever ... \
};
myclass.h:
myclass.h:
#define CLASS_NAME MyClass
#define CLASS_VARIABLES (a, b, c, x, y, z)
#include "generator.h"
DEFCLASS
但是如果对每个源文件多次使用DEFCLASS,这将不起作用(可能是Doxygen的错误/缺陷) 。
but this will not work if you use DEFCLASS more than once per source file (probably a bug/defect of Doxygen).
这篇关于如何用Doxygen记录宏生成的类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!