5
votes

I'm using Doxygen to document some of my code. I've got a function that uses a default argument, which is specified in the header i.e.:

unsigned int CountColumns(const std::string&,const std::string& delim="");

and the corresponding implementation in the source file as:

unsigned int CountColumns(const string& input,const string& delim)
{
   ...
}

When I use Doxygen to generate my documentation, CountColumns has two entries - one including the default value, and one without:

unsigned int    CountColumns (const string &input, const string &delim)
unsigned int    CountColumns (const std::string &, const std::string &delim="")

How can this be avoided? I don't want multiple function definitions cluttering up my documentation.

EDIT: As I've also mentioned in my answer below, the problem appears to be due to the fact that the header file uses 'std::string' in the arguments, while the source file includes a 'using std::string' statement and then uses 'string' in the arguments. If I alter the function definition to use 'std::string' in the source file also, Doxygen recognises it to be the same function as declared in the header.

3
Are you running doxygen to document the implementation? - David Rodríguez - dribeas
I'm asking it to include source files so that I get direct links from my documentation to source code in html form, as well as document which functions reference which others. Is that what you mean? (Sorry, I'm still learning the doxygen options). I've got the "INLINE_SOURCES" option set to NO, though. - Wheels2050

3 Answers

5
votes

I suggest to set BUILTIN_STL_SUPPORT to YES in your configuration file, so doxygen knows string is a class defined in the std namespace.

2
votes

The problem appears to be due to the fact that the header file uses 'std::string' in the arguments, while the source file includes a 'using std::string' statement and then uses 'string' in the arguments. If I alter the function definition to use 'std::string' in the source file also, Doxygen recognises it to be the same function as declared in the header.

While not ideal, it is a solution that works and is not too unwieldy.

0
votes

Well how about excluding the extra functions from the documentation ?

this is from the 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 

PREPROCESSING = YES. "