Doxygen语法

574 阅读2分钟

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:

  1. www.doxygen.nl/manual/comm…
  2. www.doxygen.nl/manual/docb…