Doxygen生成美丽注释文档(1):初体验

Hello Doxygen

[TOC]

Chapter 1 - 准备工作 (Windows环境)

1.1 程序包下载

  1. Doxygen
  • 源码: git clone https://github.com/doxygen/doxygen.git

  • GUI版本:点击下载

  • 便携压缩包版本:下载 32位版本 64位版本

  1. HTML Help Workshop

用于生成CHM文件,便于传播和查看。

Htmlhelp.exe

  1. Graphviz

用于绘制DOT语言标本描述的图形。Doxygen 使用 graphviz 自动生成类之间和文件之间的调用关系图。

  1. Sublime + DoxyDoxygen 插件

1.2 安装教程

Chapter 2 - 初尝 Doxygen

2.1 为源代码生成文档大致分为两个步骤:

  1. 为源代码编写符合 doxygen 要求的注释

  2. 使用 doxygenwizard 生成文档

2.2 编写 Doxygen 注释

/**< 标准输入输出头文件 */
#include <stdio.h>

/**
 * @brief      { Calculate the sum of two doubles }
 *
 * This function will return the sum of two doubles
 *
 * @param[in]  a     { the first number }
 * @param[in]  b     { the second number }
 *
 * @return  double   {  the sum of a and b  }
 */
double add(double a,double b)
{

    return a+b;
}

/**
 * @brief      { Calculate the different of two doubles }
 * 
 * This function will return the different of two doubles
 * 
 * @param[in]  a     { the first number }
 * @param[in]  b     { the second number }
 *
 * @return  double   { the different of a and b }
 */
double subtract(double a,double b)
{
    return a-b;
}

/**
 * @brief      { Calculate the product of two doubles }
 * 
 * This function will return the product of two doubles
 *
 * @param[in]  a     { the first number }
 * @param[in]  b     { the second number }
 *
 * @return  double   { the product of a and b }
 */
double multiply(double a,double b)
{
    return a*b;
}

/**
 * @brief      { Calculate the quotient of two doubles }
 * 
 * This function will return the quotient of two doubles
 * 
 * @param[in]  a     { the first number }
 * @param[in]  b     { the second number }
 *
 * @return  double   { the quotient of a and b }
 */
double divide(double a,double b)
{
    return a/b;
}

/**
 * @brief      { This is the main function }
 *
 * This function is the main function. 
 * It will print something in the screen.
 * 
 * @return  int   { The exit code. }
 */
int main(void)
{
    int a = 5,b = 6;
    printf("%lf\n",add(a,b));
    printf("%lf\n",subtract(a,b));
    printf("%lf\n",multiply(a,b));
    printf("%lf\n",divide(a,b));

    return 0;
}

Doxygen 命令规范文档:官网

2.3 使用 Doxygen 生成文档

步骤:

  1. 打开 doxywizard
  2. 设置工作目录、项目名称、源文件目录、生成文档的目录等
  3. 设置注释抽取的模式、语言种类
  4. 设置输出格式
  5. 设置如何输出图表
  6. 生成文档

猜你喜欢

转载自www.cnblogs.com/yqmcu/p/10090821.html
今日推荐