首页 > 其他 > 详细

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

时间:2018-12-09 15:12:23      阅读:146      评论:0      收藏:0      [点我收藏+]

Hello Doxygen

[TOC]

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

1.1 程序包下载

  1. Doxygen
  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. 生成文档
?

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

原文:https://www.cnblogs.com/yqmcu/p/10090821.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!