Linux下Doxygen安裝及使用大全
一. 安裝
1. 源碼安裝
# 下載
wget http://www.stack.nl/~dimitri/doxygen/download.html
# 解壓
tar xvfz doxygen-1.7.4.linux.bin.tar.gz
cd doxygen-1.7.4
# 編譯及安裝
./configure
make
make install
2. 命令安裝
ubuntu安裝:
sudo apt-get install doxygen
sudo apt-get install graphviz
CentOS安裝:
yum install doxygen
yum install graphviz
Mac安裝:
brew install doxygen
brew install graphviz
二. 編寫Doxygen可識別的註釋
1. 實用標記
標記 | 含義 |
---|---|
@author | 註釋作者 |
@date | 註釋日期 |
@copyright | 註釋版權 |
@struct | 註釋一個結構體 |
@union | 註釋一個聯合體 |
@enum | 註釋一個枚舉體 |
@fn | 註釋一個函數 |
@var | 註釋一個變量. |
@def | 註釋一個 #define. |
@typedef | 註釋一個 type definition. |
@file | 註釋一個文件. |
@namespace | 註釋一個命名空間. |
@package | 註釋一個 Java package. |
@interface | 註釋一個 IDL interface. |
2. 註釋模板
本文采用的是Javadoc風格的註釋,具體的註釋模板如下:
a. 文件註釋, 放於文件的開頭
/**
* @file hello.h
* @brief This is a brief description.
* @details This is the detail description.
* @author author
* @date date
* @version A001
* @par Copyright (c):
* XXX公司
* @par History:
* version: author, date, desc\n
*/
b. 函數註釋, 放於函數聲明前
/**
* This is a brief description.
* This is a detail description.
* @param[in] inArgName input argument description.
* @param[out] outArgName output argument description.
* @retval OK 成功
* @retval ERROR 錯誤
* @par 標識符
* 保留
* @par 其它
* 無
* @par 修改日誌
* XXX於201X-XX-XX創建
*/
c. 類型/宏定義註釋,放於宏定義上方或者右側
/** Description of the macro */
#define XXXX_XXX_XX 0
或者
#define XXXX_XXX_XX 0 ///< Description of the macro.
d. 枚舉/結構體註釋, 放於數據結構定義前
/**
* The brief description.
* The detail description.
*/
typedef struct
{
int var1;///<Description of the member variable
}XXXX;
e. 全局和靜態變量
/** Description of global variable */
int g_xxx = 0;
static int s_xxx = 0; ///< Description of static variable
參考: