狮城风华新都:Doxygen 源代码文档自动生成器的使用笔记 - Beginning to 编程 - C...

来源:百度文库 编辑:中财网 时间:2024/04/27 23:24:46

在 google 上搜了很久的关于 Doxygen 使用方法的咚咚,只不过都是英文,而且都很多的规则。实际上大家只需要告诉基本的规则就可以。下面是我对 Doxygen 的摸索

 

首先熟知 Doxygen 产生的文件的基本结构 ( 以 Html 和 1.4.6 为例 )

Header (头部)

MainPage  Files  Classes

 

那么我们首先建立两个类吧,以典型的 Shape 和 它的继承类 Rectangle 为例

(为了表示那些是我的解释约定 ~ 为解释符号 其他的头文件和源文件的具体内容)

// shape.h

 

~ 在这个头文件中首先要有一些关于本文件的一些信息或者公司的 copyright 信息

~ 至于你想写什么,发挥你的创意把。

 

/** \file 

 *

Richard Zeng Shape Class File Source

   ~

 为居中显示 

Copyright and Use

 

* \author Richard Zeng

* \date 2006-3-23

 

~ \author 和 \date 是 Doxygen 的两个关键字

\author 为作者标题

  \date 为日期标题

 

*

zengyongjoy@gmail.com

  All rights reserved.

*/

 

 

/** class shape define

 * this is the base class for all Shape

 */

 

~ 在 Shape 类定义的前面请加上解释,否则这个类就不会产生很重要的

 

class Shape{

public :

       Shape();

       ~Shape();

 

       virtual void Draw(CDC* pDC);

};

 

 

// shape.cpp

 

/** \file

*

Richard Zeng Shape Class File Source

 

Copyright and Use

 

* \author Richard Zeng

* \date 2006-3-23

 

*

zengyongjoy@gmail.com

All rights reserved.

*/

 

~ 上面的就不用说了吧

#include "shape.h"

 

~ 解释,随便你写什么都可以的

~ 这里我们可以看出在 CPP 中加注释比较好

~ 每个函数的实现都必须加上注释否则就没有这个函数拉

 

/** default constructor*/

Shape ::Shape()

{

 

}

 

/** destructor */

Shape ::~Shape()

{

 

}

 

 

/** Draw funtion for this shape

 * \param CDC* pointer to MFC CDC

 */

 

~ \param 为 Doxygen 的关键字 用于定义参数

~ \return 为返回关键字

void Shape::Draw(CDC* pDC)

{

 

}

 

//Rectangle.h

/** \file __FILE__

*

Richard Zeng Shape Class File Source

 

Copyright and Use

 

* \author Richard Zeng

* \date 2006-3-23

 

*

zengyongjoy@gmail.com

All rights reserved.

*/

 

 

#include "shape.h"

 

 

/** Rectangle class define

*/

class Rectangle:publicShape{

public :

       Rectangle();

       ~Rectangle();

 

       void Draw(CDC*pDC);

 

private :

       int width,height;

};

 

 

//Rectangle.cpp

 

/** \file __FILE__

*

Richard Zeng Shape Class File Source

 

Copyright and Use

 

* \author Richard Zeng

* \date 2006-3-23

 

*

zengyongjoy@gmail.com

All rights reserved.

*/

 

 

/** default constructor */

Rectangle ::Rectangle()

{

 

}

 

/** destructor */

Rectangle ::~Rectangle()

{

 

}

 

 

/** Draw function

 * \param CDC* pointer to MFC CDC Class

 */

void Rectangle::Draw(CDC* pDC)

{

 

}


  

 

下面是 Doxygen 的主要操作步骤

首先我们在 MainPage 中看到 ProjectName 和 ProjectVersion (在 Doxygen Wizhard Step1

中输入就可以啦 )

    

 

 

 

 

 

 

 

 

 

 

 

 

 

 

然后在 Step2

中选择保存文件的位置

 

Step3 选择工作目录

Step4 点击 Start 按钮, ok 完成。

打开输出文件的位置。 Html 文件就生成拉。