OpenCASCADE Documentation System
eryar@163.com
Abstract. Doxygen is the de facto standard tool for generating documentation from annotated C++ sources, but it also supports other popular programming languages. You can also use doxygen for creating normal documentation, as OpenCASCADE did for its references and user’s guide documents.
Key Words. OpenCASCADE, Doxygen, Documentation System
1. Introduction
Doxygen基本上已經(jīng)成了從C++代碼生成文檔的一個(gè)標(biāo)準(zhǔn)工具。OpenCASCADE就利用Doxygen來根據(jù)源代碼生成References文檔,還利用其生成HTML和PDF格式的User Guide文檔。使用Doxygen來生成文檔,只需要按照一定的格式,就可以自動(dòng)生成看上去比較專業(yè)的文檔。
本文主要對(duì)Doxygen用來生成User Guide的方法做一定的介紹。根據(jù)代碼生成References文檔的方法請(qǐng)參考Doxygen的文檔說明。
Figure 1.1 Doxygen GUI
2. Prerequisites
為了自動(dòng)生成PDF格式的文檔,還需要準(zhǔn)備全如下工具:
v Doxygen 1.8.4版本及以上;
v Graphviz的Dot,用來生成文檔中的類圖;
v MikTeX:用來生成PDF格式的文檔;
v Inkscape:只有當(dāng)要生成PDF格式中帶有SVG格式的圖片時(shí)需要;
v MathJax:當(dāng)生成的HTML或CHM中有數(shù)學(xué)公式時(shí)需要;
這些工具都可以從網(wǎng)上下載得到。
3. Markdown Support of Doxygen
Markdown支持是從Doxygen1.8.0開始的,Markdown就是還格式語(yǔ)法的普通文本,由John Gruber編寫,其目的是:
The design goal for Markdown’s formatting syntax is to make it as readable as possible. The idea is that a Markdown-formatted document should be publishable as-is, as plain text, without looking like it’s been marked up with tags or formatting instructions. While Markdown’s syntax has been influenced by several existing text-to-HTML filters, the single biggest source of inspiration for Markdown’s syntax is the format of plain text email.
當(dāng)你按照Markdown格式來寫文檔時(shí),只需要將*.md文件放到文檔文件夾中,Doxygen會(huì)自動(dòng)搜索并生成相對(duì)應(yīng)的文檔。這里列舉幾個(gè)Markdown的例子。
3.1 Tables表格
生成表格可以用如下的文本來表示:
生成的表格樣式如下圖所示:
Figure 3.1 Tables in Markdown
3.2 Code Blocks代碼片段
使用~~來隔離代碼,若在其帶上后綴名,還將根據(jù)后綴名來給代碼高亮。如下所示為給C++代碼著色:
Figure 3.2 Code blocks in Markdown
小段代碼著色也可用標(biāo)記@code和@endcode來標(biāo)記。
3.3 Images插入圖片
插入圖片使用如下標(biāo)記:
Figure 3.3 OCC logo
4. Conclusion
使用OCC這種方式來生成文檔,感覺還是很不錯(cuò)的。我就使用這種方式生成了程序IsoAlgo的文檔,看上比較專業(yè),如下圖所示:
Figure 4.1 IsoAlgo User Guide