Before we start discussing this recipe, open the following link and have a look at it:
http://www.openscenegraph.org/documentation/OpenSceneGraphReferenceDocs/
Some of you may say: "Oh, this is a wonderful reference guide for me during the programming work. It's impossible to keep all the classes in mind, and it's really rough to search for one method or function in the vast source directory. I'd love to have such a handy API document. But how did you make it, and how do you keep it fresh?"
Believe it or not, all this documenting work could be done by automatic generators, for example, Doxygen in our case. It will parse the source code and comments in prescribed forms, and output formatted results to HTML pages, or even CHM files.
And with the well-written build scripts, OSG can create such API documentation with the Doxygen tool in a very simple way.
Download the Doxygen tool first, and you can generate beautiful documents from the source code. The download link is:
http://sourceforge.net/projects/doxygen/files/
There is a dot utility created by the Graph Visualization Software. It can draw some types of hierarchical graphs and thus makes life more colorful. The toolkit can be found at:
http://www.graphviz.org/Download..php
Ubuntu users can install these two utilities with the apt-get
command directly by running the following two command lines:
# sudo apt-get install doxygen
# sudo apt-get install graphviz
Lastly, Windows users may choose to compile a CHM file. Microsoft HTML Workshop is required in this situation. If you don't have one, download it at:
http://www.microsoft.com/downloads/en/details.aspx?FamilyID=00535334-c8a6-452f-9aa0-d597d16580cc
1. Start the
cmake-gui
window. Don't worry about a completely new compilation, which may take another few hours again. This time we are going to configure options for documentation building only.2. Find the
BUILD
group and click onBUILD_DOCUMENTATION
. Click on Configure for more choices.3. A new group named
DOXYGEN
appears after reconfiguring. Look into the group and ensure that thedoxygen
anddot
executables are set properly. Windows users may have to specify the locations ofdoxygen.exe
anddot.exe
manually.4. Another group
DOCUMENTATION
is used to decide whether we should build with the optionHTML_HELP
(CHM file). Selecting it means we are going to compile HTML documents into a CHM file. It requireshhc.exe
from the HTML Workshop as the executable.5. For Windows users only, set up the location of
hhc.exe
and the Html Help SDK library. The latter can be found in the Windows SDK distribution.6. The common
make
andmake install
commands won't affect the generation of API documents. Use the following commands to obtain the OpenThreads and OpenSceneGraph API documents:# sudo make doc_openthreads # sudo make doc_openscenegraph
7. Use any browser to open the
index.html
file in the/doc/OpenSceneGraphReferenceDocs/
folder in your build directory. See what great work you have just done!
If you have generated Visual Studio solution files, find the sub-project DoxygenDoc
and build it separately. The ALL_BUILD
and INSTALL
projects, which must be run to compile and install all OSG libraries and applications, can never affect the compilation of documents, and vice versa. So you may build the API documents without building OSG.
Note
Interested in the generation of API documents? Or do you want your own project to be documented in such an automatic process too? Change your commenting habit from now on. Doxygen will try to recognize some special forms of comments and create great-looking and practical reference manuals for you. See the link below for more details: