Nap*_*ali 9 c++ comments doxygen
您是否可以使用单个注释块来评论doxygen中的多个函数?下面是一个不起作用的简单示例.我可以做类似的事情来获得我想要的东西吗?
file.cpp
#include file.h
/// @name FunsGroupedInDoxygen
///@{
/**
* @brief Documentation for 2 functions
* @param aParam A Parameter
* @retval 0 will always be returned
*/
int fun1(int aParam) {return 0;}
int fun2(int aParam) {return 0;}
///@}
Run Code Online (Sandbox Code Playgroud)
file.h
int fun1(int aParam);
int fun2(int aParam);
Run Code Online (Sandbox Code Playgroud)
氧气输出:
警告:文件file.h的成员fun2(int aParam)(函数)未记录.
Tuf*_*wer 10
在Doxygen手册中查看分组,您可以使用几种方法.我认为最符合这种情况的是会员组.
您可以使用以下两种样式之一定义成员组:
///@{
...
///@}
Run Code Online (Sandbox Code Playgroud)
要么
/**@{*/
...
/**@}*/
Run Code Online (Sandbox Code Playgroud)
一个例子是:
/** @name FunctionGroup
* @brief Documentation for 2 functions
* @param aParam A Parameter
* @retval 0 will always be returned
*/
///@{
//* fun1 specific description */
int fun1(int aParam) {return 0;}
//* fun2 specific description */
int fun2(int aParam) {return 0;}
///@}
Run Code Online (Sandbox Code Playgroud)
这允许您定义一个可以提供通用描述的组,并且仍然允许您删除特定于创建的doxygen文件中的每个函数的注释.
我没有在我所在的计算机上安装doxygen并且无法直接测试此代码,但是如果遵循文档中成员组部分的group2的示例,则此处显示该示例的编译输出,希望是你想要的输出.
在测试之前确实为我工作但仅当我将所需的提取模式设置为所有实体时(doxyfile中的EXTRACT_ALL = YES).最好只使用实际记录的实体,所以我花了一些时间尝试从上面提到的文档中采用不同的方法.
file.h:
/**
* \defgroup FunctionGroup A Group of Functions
* @brief Documentation for 2 functions
* @param aParam A Parameter
* @retval 0 will always be returned
* @{
*/
int fun1(int aParam);
int fun2(int aParam);
/** @} */
Run Code Online (Sandbox Code Playgroud)
file.cpp:
#include file.h
/** @ingroup FunctionGroup
* @brief fun1 specific description
*/
int fun1(int aParam){
return 0;
}
/** @ingroup FunctionGroup
* @brief fun2 specific description
*/
int fun2(int aParam){
return 0;
}
Run Code Online (Sandbox Code Playgroud)
这是我在这两个文件上运行Doxygen时得到的输出图像:

我在windows机器上使用了doxywizard,我生成的doxyfile 在pastebin上.
我不确定单个注释块,但是这样做的简洁方法是使用@copydoc(这里引用),例如:
/**
* @brief Brief description
* @param aParam A parameter
*/
void foo(int aParam) {}
/**
* @copydoc foo(int)
*/
void bar(int aParam) {}
Run Code Online (Sandbox Code Playgroud)