文章目录
- 配置 doxygen
- 代码中判断宏
配置 doxygen
定义自己的宏 HAL_CONFIG_USB
代码中判断宏
@if HAL_CONFIG_USB
your contents
@endif
需要注意的是 Doxygen不支持直接的 @elif
指令。Doxygen只提供了 @if
和 @endif
指令来实现条件性文档生成。如果您需要多个条件进行判断,可以使用多个 @if
指令来实现,例如:
/**
* @file example.h
* @brief This is an example header file.
*/
#ifndef EXAMPLE_H
#define EXAMPLE_H
/**
* @brief This is a function that gets documented based on multiple conditions.
*
* @param[in] condition The condition to be checked.
*
* @if (HAL_CONFIG_USB)
* This block is documented if condition is HAL_CONFIG_USB.
* @endif
*
* @if (HAL_CONFIG_USBH)
* This block is documented if condition is HAL_CONFIG_USBH.
* @endif
*
* @if (HAL_CONFIG_USBD)
* This block is documented if condition is HAL_CONFIG_USBD.
* @endif
*/
void conditionalFunction(int condition);
#endif // EXAMPLE_H
请确保每个 @if
都有对应的 @endif
来正确关闭条件块