James Zhang: if we develop a class library ourselves, how can we make a convenient document?
Li Si: Write it in one way, just like writing an Excel document.
Michael Zhang: Ah, you are out. How slow is it. Why can't I use the doxygen tool to generate documents for you?
Li Si: It's so cool. Let's talk about it.
1. doxygen, what?
Doxgen is a well-known documentation generation tool and is free and open-source. It is very convenient to use and can extract C ++, Java, objective-C, Python, IDL, PHP, C # and other language annotations to generate documents.
You can visit its official website to download the installation package. its official website contains detailed user manuals.
Http://www.doxygen.nl/index.html
Supported major language formats
Extension |
Language |
. IDL |
IDL |
. DDL |
IDL |
. Odl |
IDL |
. Java |
Java |
. CS |
C # |
. C |
C |
. Cpp |
C ++ |
The following formats can be generated:
To enable the tool to extract comments, the comments you write must follow certain rules and cannot be written in disorder. Otherwise, the tool cannot be identified. Generally, in Java, as long as javadoc can recognize anything else, doxgen can also recognize it.
2. Install doxygen
We can download the latest installation package at this URL.
Http://www.doxygen.nl/download.html#latestsrc
The installation process is not required. It is very simple. Click Next and finish the installation.
3. Configure doxygen
Configuration of doxgen is the core. You can set the source files to be annotated, the generated document format, project name, document logo, and other information. These configurations can be stored, after updating your source code, run the configuration file again to generate a new document.
After installation, go toBinFolder, which contains two files: doxygen.exeand doxywizard.exe. we first run doxywizard.exe to configure the file to generate a configuration file (if it is the first time running ).
Figure 1. Main Interface for doxygen configuration.
1. The doxygen working directory is the directory used to store configuration files.
2. Select the recursive search directory.
Figure 2. Select the output document format
Figure 3: generate a class chart
Figure 4. Select the document encoding format.
(Encoding format, UTF-8 is the first choice. Select gb2313 if you want to display Chinese characters.
Figure 5. Set the extraction range.
Figure 6 sets the source code format.
Figure 7. Set the CHM File generation attributes.
Figure 8. After the configuration is complete, click "Run doxygen" to run the configuration. Finally, click File-> Save to store the configuration file. You will not need to configure it again next time.
4. output document example
The following figure shows the output document format (HTML), which is simple and practical and supports search.
Figure 9. list all package names.
Figure 10. Detailed comments of a specific class list all public methods. The more detailed your code comments are, the more detailed the generated documents will be.