我需要使用doxygen来记录项目,但是还需要忽略一些宏,我在代码的一小部分中使用这些宏来实现可读性,因此在文档中出现是没有意义的。
这是一个最小的例子(我主要使用宏来索引一些C风格的2D或3D数组):
#include <cstring>
/*! \file notes.cpp
\brief A test for macros and doxygen
*/
/// my main function
int main ()
{
double loc_arr[9][4][4];
memset (loc_arr, 0.0, 144 * sizeof (double));
#define BLOCK(i) (&(loc_arr[i][0][0]))
for (int ii = 0; ii < 9; ++ii)
{
memset (BLOCK(ii), double(ii), 16 * sizeof (double));
}
#undef BLOCK
return 1;
}
当我执行它时,使用以下设置:
ENABLE_PREPROCESSING = YES
MACRO_EXPANSION = YES
EXPAND_ONLY_PREDEF = NO
SEARCH_INCLUDES = YES
INCLUDE_PATH =
INCLUDE_FILE_PATTERNS =
PREDEFINED =
EXPAND_AS_DEFINED =
SKIP_FUNCTION_MACROS = YES
我得到了这个:
screenshot http://i39.tinypic.com/2rf583c.png
请注意,我可以避免记录宏的唯一方法是设置ENABLE_PREPROCESSING = NO
,这对我来说是一个问题,因为它也消除了页面顶部的包含图。
答案 0 :(得分:5)
选项1。您可以使用预处理器符号DOXYGEN_SHOULD_SKIP_THIS
,如doxygen FAQ
How can I make doxygen ignore some code fragment?
The new and easiest way is to add one comment block with a
\cond command at the start and one comment block with a
\endcond command at the end of the piece of code that should be
ignored. This should be within the same file of course.
But you can also use doxygen's preprocessor for this: If you put
#ifndef DOXYGEN_SHOULD_SKIP_THIS
/* code that must be skipped by Doxygen */
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
around the blocks that should be hidden and put:
PREDEFINED = DOXYGEN_SHOULD_SKIP_THIS
in the config file then all blocks should be skipped by doxygen
as long as ENABLE_PREPROCESSING is set to YES.
选项2。您可以使用 doxygen的EXCLUDE_SYMBOLS配置选项。
答案 1 :(得分:2)
实现此目的的一种方法是使用\cond-@cond doxygen命令:
#include <cstring>
/*! \file notes.cpp
\brief A test for macros and doxygen
*/
/// my main function
int main ()
{
double loc_arr[9][4][4];
memset (loc_arr, 0.0, 144 * sizeof (double));
/// \cond DO_NOT_DOCUMENT
#define BLOCK(i) (&(loc_arr[i][0][0]))
for (int ii = 0; ii < 9; ++ii)
{
memset (BLOCK(ii), double(ii), 16 * sizeof (double));
}
#undef BLOCK
/// \endcond
return 1;
}