目錄
- doc檔案夾
- 幫助檔案
- qdoc工具
- doxygen工具
- 組態檔
- qtcreator-project.qdocconf
- qtcreator-developer.qdocconf
- 幫助檔案
doc檔案夾
對于bin和dist檔案夾這里就不做過多的介紹了,我們首先來重點關注doc檔案夾,對于理解原始碼,幫助檔案總是能起到非常有效的作用,其實,我們在第一章《目錄介紹》中已經對doc檔案夾進行了一個大概的介紹,
幫助檔案
幫助檔案的來源有兩個組成部分:
-
源代碼中的注釋
-
qdoc檔案
兩者都采用一定約束規范的撰寫形式,來添加注釋和說明資訊,示例如下:
/*!
\class XXX
\brief The brief description of the class XXX
\details The details description of the clss XXX
*/
qdoc工具
qt使用qdoc.exe軟體來制作幫助檔案,軟體需要qdocconf組態檔,該檔案描述了檔案來源和相關配置引數等,
對于qdoc.exe怎么使用,這里就不再展開了,請自行查閱相關資料,示例如下:
...\bin\qdoc.exe --outputdir ./my-html-doc-qtcreator qtcreator.qdocconf
doxygen工具
這里我們討論一下doc\doxygen檔案夾,里面只有一個Doxyfile檔案,
這是檔案夾干什么用的呢?不知道大家日常看大牛的開源代碼時,是否時常感嘆為什么別人的代碼寫的那么的優雅,大段大段的注釋那么有結構,官方幫助檔案那么的清晰完整!!
想必大家都明白了吧,他們采用的就是doxygen工具,該工具從相關的代碼源檔案中生成檔案,包括html,pdf,unix man page等,只要你按照doxygen的代碼注釋規范來撰寫注釋,即可使用該工具生成檔案,
這里doxyfile的作用和qdocconf是一樣的,就是組態檔,具體內容請參考官網,
它支持qt,java等多種風格,qt風格如下,這跟qdoc中使用的差不了多少:
//! A test class.
/*!
A more elaborate class description.
*/
class QTstyle_Test
{
public:
//! An enum.
/*! More detailed enum description. */
enum TEnum {
TVal1, /*!< Enum value TVal1. */
TVal2, /*!< Enum value TVal2. */
TVal3 /*!< Enum value TVal3. */
}
//! Enum pointer.
/*! Details. */
*enumPtr,
//! Enum variable.
/*! Details. */
enumVar;
//! A constructor.
/*!
A more elaborate description of the constructor.
*/
QTstyle_Test();
//! A destructor.
/*!
A more elaborate description of the destructor.
*/
~QTstyle_Test();
//! A normal member taking two arguments and returning an integer value.
/*!
\param a an integer argument.
\param s a constant character pointer.
\return The test results
\sa QTstyle_Test(), ~QTstyle_Test(), testMeToo() and publicVar()
*/
int testMe(int a,const char *s);
//! A pure virtual member.
/*!
\sa testMe()
\param c1 the first argument.
\param c2 the second argument.
*/
virtual void testMeToo(char c1,char c2) = 0;
//! A public variable.
/*!
Details.
*/
int publicVar;
//! A function variable.
/*!
Details.
*/
int (*handler)(int a,int b);
};
生成的html檔案驚鴻一瞥:
組態檔
qtcreator編譯時,會自動生成幫助檔案,如果你安裝了qt,可以在QtTargetPath[1]\Tools\QtCreator\share\doc\qtcreator檔案夾下發現這些幫助檔案,
doc檔案夾中最核心的兩個組態檔為config子檔案夾下的qtcreator-project.qdocconf和qtcreator-developer.qdocconf,
qtcreator-project.qdocconf
該組態檔生成的html幫助手冊,用于介紹qtcreator軟體如何使用的,我們可以在qtcreator軟體的幫助模式中看到的,html檔案在上述安裝路徑的qtcreator子檔案夾中,
qtcreator-project.qdocconf具體如下:
# 設定源路徑
headerdirs =
sourcedirs = ../src
imagedirs = ../images \
...
...
# 包含通用配置
include(macros.qdocconf)
include(qt-cpp-ignore.qdocconf)
include(qt-defines.qdocconf)
# 過濾檔案尾綴
sources.fileextensions = "*.qdoc"
# 設定屬性
qhp.projects = QtCreator
qhp.QtCreator.file = qtcreator.qhp
qhp.QtCreator.namespace = org.qt-project.qtcreator.$QTC_VERSION_TAG
qhp.QtCreator.virtualFolder = doc
# 標題
qhp.QtCreator.indexTitle = Qt Creator Manual $QTC_VERSION
...
下面是軟體幫助模式的截圖,
qtcreator-developer.qdocconf
該組態檔生成的html幫助手冊,用于介紹如何擴展qtcreator軟體的功能,以及擴展會用到的相關類,html檔案在上述安裝路徑的qtcreator-dev子檔案夾中,
qtcreator-dev.qdocconf具體如下:
# 設定源路徑
headerdirs = . \
../api \
../../src/libs/aggregation \
...
sourcedirs = . \
../api \
../../src/libs/aggregation \
...
...
# 過濾檔案尾綴
headers.fileextensions = "*.h"
sources.fileextensions = "*.cpp *.qdoc"
...
# 包含通用配置
include(macros.qdocconf)
include(qt-cpp-ignore.qdocconf)
include(qt-defines.qdocconf)
# 設定屬性
qhp.projects = QtCreatorDev
qhp.QtCreatorDev.file = qtcreator-dev.qhp
qhp.QtCreatorDev.namespace = org.qt-project.qtcreator.developer.$QTC_VERSION_TAG
qhp.QtCreatorDev.virtualFolder = doc
# 標題
qhp.QtCreatorDev.indexTitle = Extending Qt Creator Manual
...
下面是html幫助手冊的截圖,
下面開始,我們對生成的Extending Qt Creator Manual幫助檔案進行學習,
原創造福大家,共享改變世界
獻出一片愛心,溫暖作者心靈
QtTargetPath為Qt的安裝目錄,不是qt creator, ??
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/17786.html
標籤:其他
