程序文档,曾经是程序员的一个头痛问题。写一个程序文档,比较花时间,但不是很难;麻烦的是当程序修改后,程序文档也要跟着同步更新,否则文档和程序就要脱节,文档也就变成没用的东西了。
好在有许多好用的文档生成器来解决这个问题。目前比较流行的C++文档生成器是doxygen。
本文就简单的介绍一下doxygen的文档注释方法,以供初学者参考:
C++ 程序文档生成器介绍(doxygen) 沐枫网志
* A list of events:
* - mouse events
* -# mouse move event
* -# mouse click event/n
* More info about the click event.
* -# mouse double click event
* - keyboard events
* -# key down event
* -# key up event
*
* More text here.
*/
结果为:
A list of events:
- mouse events
- mouse move event
- mouse click event
More info about the click event. - mouse double click event
- keyboard events
- key down event
- key up event
More text here.
































































































































今天下午看了看Doxygen的文档,把一些自己认为比较常用的TAG注解了一下,本想全部翻译的,可是后来看了一遍之后,就懒了,太多了,嘿嘿,就做个摘要算了吧。嘿嘿
<> 里面的是必须的,{}表示可选的:
@a <word> 用斜体显示后面跟随的一个词
@anchor <word> 标记锚点
@arg { item-description } @arg @c 参数的描述
@attention { attention text } 标记需要注意的段落
@author { list of authors } 作者
@b <word> 用粗体显示后面跟随的一个词
@brief {brief description} 概要
@bug { bug description } 臭虫
@c <word> 打字机字体
@class <name> [<header-file>] [<header-name>] 类
@date { date description } 日期
@def <name> 宏描述
@deprecated { description } 废弃的
@e <word> 斜体字
@em <word> 斜体字
@enum <name> 描述enum,比如:
/*! @enum Test::TEnum
* A description of the enum type.
*/
@example <file-name> 例子文件
@exception <exception-object> { exception description }异常描述
@f$ 公式
@f[ 公式
@f] 公式
@file [<name>] 文件说明
@fn (function declaration) 函数说明
@htmlonly 后面的东西原封不动的插入生成的html当中,直到遇到 @endhtmlonly
@image <format> <file> ["caption"] [<sizeindication>=<size>] 插入图像文件
@interface <name> [<header-file>] [<header-name>] 描述接口和@class同意
@link <link-object> 插入链接
@n 强制新行
@namespace <name> 名字空间
@note { text } 注解
@overload [(function declaration)] 重载
@p 打字机字体
@property 属性说明
@ref <name> ["(text)"] 引用锚点
@remarks { remark text } 备注
@return 返回值
@retval 返回值列表
@sa =@see 参见
@section 段落
@see 参见
@struct 结构
@test { paragraph describing a test case }
@throw = @exeception
@todo { paragraph describing what is to be done } 要完成的任务
@typedef
@union
@var (variable declaration) 变量
@version { version number } 版本号
@warning { warning message } 警告
@$
@@
@@
@&
@~
@<
@>
@#
@%
生成列表:
在每个行的开始处以“-”打头,以下缩进对齐,列表每项也以“-”打头。
下面是Doxygen所有的标签:
@a <word> 用斜体显示后面跟随的一个词
@addindex (text)
@addtogroup <name> [(title)]
@anchor <word> 标记锚点
@arg { item-description } @arg @c 参数的描述
@attention { attention text } 标记需要注意的段落
@author { list of authors } 作者
@b <word> 用粗体显示后面跟随的一个词
@brief {brief description} 概要
@bug { bug description } 臭虫
@c <word> 打字机字体
@callgraph
@category <name> [<header-file>] [<header-name>] Object-c Only
@class <name> [<header-file>] [<header-name>] 类
@code
@cond [<section-label>]
@copydoc <link-object>
@date { date description } 日期
@def <name> 宏描述
@defgroup <name> (group title)
@deprecated { description } 废弃的
@dir [<path fragment>]
@dontinclude <file-name>
@dot
@dotfile <file> ["caption"]
@e <word> 斜体字
@else
@elseif <section-label>
@em <word> 斜体字
@endcode
@endcond
@enddot
@endhtmlonly
@endif
@endlatexonly
@endlink
@endmanonly
@endverbatim
@endxmlonly
@enum <name> 描述enum,比如:
/*! @enum Test::TEnum
* A description of the enum type.
*/
@example <file-name> 例子文件
@exception <exception-object> { exception description }异常描述
@f$ 公式
@f[ 公式
@f] 公式
@file [<name>] 文件说明
@fn (function declaration) 函数说明
@hideinitializer
@htmlinclude
@htmlonly 后面的东西原封不动的插入生成的html当中,直到遇到 @endhtmlonly
@if <section-label>
@ifnot <section-label>
@image <format> <file> ["caption"] [<sizeindication>=<size>]
@include <file-name>
@includelineno <file-name>
@ingroup (<groupname> [<groupname> <groupname>])
@internal
@invariant
@interface
@latexonly
@li
@line
@link <link-object>
@mainpage
@manonly
@n 强制新行
@name (header)
@namespace
@nosubgrouping
@note { text }
@overload [(function declaration)]
@p 打字机字体
@package
@page
@par
@paragraph
@param
@post
@pre
@private (PHP only)
@privatesection (PHP only)
@property
@protected (PHP only)
@protectedsection (PHP only)
@protocol
@public (PHP only)
@publicsection (PHP only)
@ref <name> ["(text)"]
@relates
@relatesalso
@remarks { remark text }
@return
@retval
@sa =@see
@section
@see
@showinitializer
@since
@skip
@skipline
@struct
@subsection
@subsubsection
@test { paragraph describing a test case }
@throw
@todo { paragraph describing what is to be done }
@typedef
@union
@until
@var
@verbatim
@verbinclude
@version { version number }
@warning { warning message }
@weakgroup
@xmlonly
@xrefitem
@$
@@
@@
@&
@~
@<
@>
@#
@%