Doxygen语法
如需转载请标明出处
QQ技术交流群:129518033
文章目录
环境:
Doxygen:1.8.5
前言
Doxygen提供了大量特殊命令,XML命令和HTML命令。可用于增强或构建注释块内的文档。如果由于某种原因需要定义新命令,则可以通过别名定义来实现。
1.特殊命令(Special Commands)简介
所有命令都以反斜杠(\)或at符号(@)开头。
这里列出常用的命令
| 命令 | 字段名 | 语法 |
|---|---|---|
| @file | 文件名 | file [] |
| @brief | 简介 | brief { brief description } |
| @author | 作者 | author { list of authors } |
| @mainpage | 主页信息 | mainpage [(title)] |
| @date | 年-月-日 | date { date description } |
| @version | 版本号 | version { version number } |
| @copyright | 版权 | copyright { copyright description } |
| @param | 参数 | param [(dir)] { parameter description } |
| @return | 返回 | return { description of the return value } |
| @retval | 返回值 | retval { description } |
| @bug | 漏洞 | bug { bug description } |
| @details | 细节 | details { detailed description } |
| @pre | 前提条件 | pre { description of the precondition } |
| @see | 参考 | see { references } |
| @link | 连接(与@see类库,{@link www.google.com}) | link |
| @throw | 异常描述 | throw { exception description } |
| @todo | 待处理 | todo { paragraph describing what is to be done } |
| @warning | 警告信息 | warning { warning message } |
| @deprecated | 弃用说明。可用于描述替代方案,预期寿命等 | deprecated { description } |
| @example | 示例 | example[{lineno}] |
2.文件注释
一般放在文件开头
/**
* @file 文件名
* @brief 简介
* @details 细节
* @author 作者
* @version 版本号
* @date 年-月-日
* @copyright 版权
*/
示例
/**
* @file Test.h
* @brief 测试头文件
* @details 测试Doxygen
* @author admin
* @version 1.0.0
* @date 2019-01-14
* @copyright MIT
*/
3.类注释
类对象的注释
/**
* @brief 类的详细描述
*/
示例
/**
* @brief The Test class
* 测试类
*/
class Test{
};
4.函数注释
/**
* @brief 函数描述
* @param 参数描述
* @return 返回描述
* @retval 返回值描述
*/
示例
/**
* @brief isExcellent 是否为优秀
* @param score 分值 0 - 100
* @return 是否为优秀
* @retval false 不是优秀
* @retval true 优秀
*/
bool isExcellent(int score);
5.常量/变量注释
一般常量/变量可以有两种形式:
- 常量/变量上一行注释
- 常量/变量后注释
5.1 常量/变量上一行注释
/// 分值
int score;
/**
* @brief score 分值
*/
int score;
5.2 常量/变量后注释
int score; /*!< 分值 */
int score; /**< 分值 */
int score; //!< 分值
int score; ///< 分值
Reference: