在Doxygen中记录条件专用代码 [英] Documenting conditional exclusive code in Doxygen
问题描述
考虑
//EXTERNAL_MACRO是由构建系统定义为某个值的外部宏#if EXTERNAL_MACRO == 1#定义EXCLUSIVE_MACRO_ONE#elif EXTERNAL_MACRO == 2#定义EXCLUSIVE_MACRO_TWO#别的#定义EXCLUSIVE_MACRO_OTHER#万一
在构建时,仅定义了EXCLUSIVE_MACRO _...宏之一.
一个文档如何在Doxygen中全部三个EXCLUSIVE_MACRO _...宏?
PREDEFINED
配置设置对此无济于事,因为它允许仅将EXTERNAL_MACRO定义为单个值(因此仅记录单个EXCLUSIVE_MACRO _...).
此SO 答案提供了一种变通解决方案,该解决方案可以完成任务,但需要附加逻辑.我正在寻找一个更简单的答案,该答案使用Doxygen配置(如果可能)而不是修改原始代码(尽管当然可以进行一些修改).
查看相关问答:用doxygen记录配置宏
基本上:
在doxygen配置文件中,添加:
PREDEFINED = IN_DOXYGEN
在源代码中的某处添加:
/*将构建配置宏导出到doxygen,这样他们就被记录在案.*/#ifdef IN_DOXYGEN#定义EXCLUSIVE_MACRO_ONE#定义EXCLUSIVE_MACRO_TWO#定义EXCLUSIVE_MACRO_THREE#endif/* IN_DOXYGEN */
然后正确获取这些宏的文档.
如果您不想更改源,可以在 PREDEFINED
中添加 EXCLUSIVE_MACRO_ONE
和朋友,而无需设置 EXTERNAL_MACRO
./p>
Consider
// EXTERNAL_MACRO is an external macro defined to some value by build system
#if EXTERNAL_MACRO == 1
# define EXCLUSIVE_MACRO_ONE
#elif EXTERNAL_MACRO == 2
# define EXCLUSIVE_MACRO_TWO
#else
# define EXCLUSIVE_MACRO_OTHER
#endif
At built time, only one of the EXCLUSIVE_MACRO_... macros is defined.
How can one document all three EXCLUSIVE_MACRO_... macros in Doxygen?
PREDEFINED
configuration setting is not helpful for this because it allows to define EXTERNAL_MACRO to only a single value (and therefore document only a single EXCLUSIVE_MACRO_...).
This SO answer offers a work-around solution that does the job but it requires an additional logic. I am looking for a simpler answer, one that uses Doxygen configuration (if possible) rather than modifying the original code (though some modification is of course fine).
See related question and answer: Document a config macro with doxygen
Basically:
In the doxygen configuration file, add:
PREDEFINED = IN_DOXYGEN
Somewhere in the source code, add:
/*
Exporting build configuration macros to doxygen,
so they get documented.
*/
#ifdef IN_DOXYGEN
# define EXCLUSIVE_MACRO_ONE
# define EXCLUSIVE_MACRO_TWO
# define EXCLUSIVE_MACRO_THREE
#endif /* IN_DOXYGEN */
Then the documentation for these macros is picked up properly.
If you don't want to change the source, you can add EXCLUSIVE_MACRO_ONE
and friends in PREDEFINED
, instead of setting EXTERNAL_MACRO
.
这篇关于在Doxygen中记录条件专用代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!