How to make doxygen ignore functional macros when creating documentation?

I need to document a project with doxygen, but I also need to ignore some macros that I use to read in small sections of my code, for which it makes no sense to appear in the documentation.

here's a minimal example (I mostly use macros to index some C-style 2D or 3D arrays):

#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;
}

When I do this, with the following settings:

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

I get the following:

screenshot http://i39.tinypic.com/2rf583c.png

Please note that the only way to avoid macros that should be documented is to establish ENABLE_PREPROCESSING = NOwhat is a problem for me, as it also excludes the inclusion schedule at the top of the page.

+4
2

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 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.. EXCLUDE_SYMBOLS Doxygen.

+5

- \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;
}
+2

All Articles