一 一般写法
通常注释写在代码前面,例如
/** @brief int value a */
int a;
int b;
二 写在代码后面
int a; /** @brief int value a */
int b;
此写法当Doxygen生成文档时其实并不是修饰的a,而是b,如果此时希望能正确修饰a,写法如下:
int a; /**< @brief int value a */
int b;
注释开始的位置需要加上<。
三 写在其他位置
注释除了前面和后面之外,Doxygen还支持识别写在其他位置的注释,此时需要一些特殊命令的支持。Doxygen支持很多命令,类似于C++的标识符,例如前面的brief就是Doxygen支持的命令之一,命令必须以@或者\开头,后面再详细探究,这里不展开。
// a.hpp
class Demo{};
// b.hpp
/**
* @class Demo
* @brief describe it in some other place.
*
*/
如上,在b.hpp中的注释可以修饰a.hpp中的Demo类。提前是b.hpp的位置能够被Doxygen读取到即可。这里使用了特殊命令class,用于Class类型,针对其他类型也有相应的特殊命令:
\struct
to document a C-struct.\union
to document a union.\enum
to document an enumeration type.\fn
to document a function.\var
to document a variable or typedef or enum value.\def
to document a #define.\typedef
to document a type definition.\file
to document a file.\namespace
to document a namespace.\package
to document a Java package.\interface
to document an IDL interface.
四 参考