0. Preface Writing comments for code has always been a problem for most programmers. Currently, programmers can all accept comments for program maintainability and readability encoding, but such questions include where to write comments, how to write comments, and how much to write, many programmers still have no answer. The biggest headache is the writing and maintenance of documents. developers can usually endure the need to write or modify the corresponding comments when writing or modifying code, however, it is difficult to modify the relevant documents. If you can directly convert a comment into a document, it is undoubtedly a blessing for developers. Doxygen can automatically convert comments in a certain format into corresponding documents. Doxygen is a GPL-based open-source project and is a very good documentation system. It currently supports running on most Unix (including Linux), windows, and MAC systems, and fully supports C ++, c, Java, IDL (the CORBA and Microsoft families) languages, some support PHP and C # languages, the output formats include HTML, latex, RTF, PS, PDF, compressed HTML, and Unix manpage. Many open-source projects (including log4cpp and cppunit introduced in the previous two articles) use the doxygen document system. There are not many developers in China. Here we will introduce this tool from the perspective of developers, so that developers can grasp this technology at the minimum cost as soon as possible, this tool is used to discuss how to write comments. The following uses the C ++ language in Linux as an example to describe how to use doxygen1.3.3.
1. Steps for using doxygen Because it is only a tool, the principle of this tool is not described here, it starts directly from the steps of use. Doxygen is easy to use. It can be divided: 1) The first time you use a program that requires doxygen Installation 2) generate the doxygen configuration file 3) write comments in a certain format during encoding 4) generate the corresponding document The installation of doxygen is very simple. in Linux, you can directly download the installation package and run it. the download of source code compilation and installation is also a common compilation and installation command. See the installation documentation to complete the installation. Doxygen can define project properties and many options during document generation when generating documents. Use the following command to generate a default configuration file:
Doxygen-G [configuration file name] You can modify the corresponding items in the configuration file according to the specific needs of the project. The specific modification process is described below. The modified configuration file can be used as a template for future projects. To enable doxygen to generate documents automatically, the standard annotation style is not acceptable. You must follow the doxygen format. For more information about how to write comments for doxygen, see section 3rd. OK. After the code is compiled, the comments are also written in the format. What is the final document? It is very simple. Run the following command and the corresponding documents will be generated in the specified directory. Doxygen [configuration file name] Note that doxygen does not process all comments. doxygen focuses on comments related to program structures, such as comments such as files, classes, structures, functions, variables, and macros, ignore comments of variable and code in the function.2. doxygen configuration file The format of the doxygen configuration file is also the format of the Common Unix configuration file: Comment '#'; tag = value [, value2…]; You can use tag + = value [, value2…] for multi-value scenarios. Modifications to the doxygen configuration file are divided into two types: one is the output option, control how to explain the source code, and the other is the project-related information, for example, the project name, source code directory, and output document directory. After setting the first option, all projects can share one configuration, and the other is required for each project. Next, select the important option that may need to be modified for explanation. Other options are described in detail in the configuration file. Default Value of tag Project_name project name Project_number can be understood as version information. The directory to which the output_directory outputs the file. The relative directory (doxygen running directory) or absolute directory Input code file or code directory, separated by Spaces File_patterns *. C *. CC *. cxx *. CPP *. c ++ *. java *. II *. ixx *. IPP *. I ++ *. INL *. H *. HH *. hxx *. HPP *. h ++ *. IDL *. odl specifies a specific file in the input directory, for example :*. CPP *. C *. h Recursive no indicates whether to recursively input sub-directories in the directory The subdirectories that exclude needs to ignore in the input directory. Exclude_patterns specifies the objects to be ignored in the input directory, such as fromout *. cpp.
Language of the document generated in output_language English. Currently, 2 or 30 languages are supported. Chinese can be set Use_windows_encoding Yes (WIN Version) No (Unix Version) encoding format, default. Extract_all no is no, and only codes with comments in doxygen format are interpreted. If yes, all codes are parsed even if no comments exist. The private members of the class and all static items are controlled by extract_private and extract_static. Extract_private no whether to resolve private members of the class Extract_static no whether to parse static items Extract_local_classes yes whether to parse the class defined in the source file (CPP file) If source_browser no is yes, the source code file will be included in the document. If inline_sources no is yes, the implementation code of functions and classes is included in the document. Alphabetical_index no generates a list of letters in alphabetical order. We recommend that you set it to yes when there are many classes and structures. Generate_html yes: whether to generate HTML documents Generate_htmlhelp no whether to generate compressed HTML format document (. CHM) Generate_latex yes: whether to use documents in latex format Generate_rtf No: whether to generate a document in the RTF Format Generate_man no whether to generate man-Format documents Generate_xml No: whether to generate a document in XML format |