贡献者: addis
/**多行注释*/ 注意两个星号表示使用 doxygen。中间每行注释习惯上以 空格* 开头,但不强制。
@brief: Provides a brief description of the function, class, or variable (including data member).
@class: Documents a class.
@param: Describes a function parameter.
@return: Describes the return value of a function.
@details: Provides a detailed description (optional).
@note: Adds a note or additional information.
@warning: Adds a warning message.
@see: References other related functions, classes, or documentation.
@code and @endcode: Inserts a code block in the documentation.
@enum: Documents an enumeration.
@file: Documents a file.
@namespace: Documents a namespace.
例子
/**
* @brief Calculates the factorial of a number.
*
* @details This function calculates the factorial of a non-negative integer
* using a recursive approach.
*
* @note The function does not handle negative inputs.
*
* @param n The number to calculate the factorial for.
* @return The factorial of the number.
*
* @code
* int result = factorial(5); // result will be 120
* @endcode
*
* @see https://en.wikipedia.org/wiki/Factorial
*/
inline int factorial(int n);
inline int factorial(int n) {
if (n <= 1) return 1;
return n * factorial(n - 1);
}
sudo apt install doxygen。
doxygen -g 生成配置文件 Doxyfile。It contains many configuration options. You can edit it to customize the documentation generation process. Here are some common settings you might want to change:
PROJECT_NAME: The name of your project.
PROJECT_BRIEF: A brief description of your project.
OUTPUT_DIRECTORY: The directory where the documentation will be generated.
doxygen Doxyfile 即可生成文档。但上面 factorial.cpp 中的说明不会生成,因为还需要手动在 Doxyfile 中设置:
EXTRACT_ALL = YES: Set this to YES to ensure all entities (including undocumented ones) are included in the documentation.
EXTRACT_STATIC = YES: Set this to YES to document static functions and variables.
RECURSIVE = YES: If your code is in subdirectories, set this to YES to scan recursively.
OUTPUT_LANGUAGE = Chinese
doxygen Doxyfile 生成就有了!