0

I am documenting my C++ code using Doxygen, and decided to do so only in the implementation files (above the function definitions), so that the header files (function declaration) stay small.

Header:

std::string color_to_hex( 
    const Color& c, 
    std::string prefix = "#", 
    bool uppercase = false 
);

Implementation:

/**
 * @brief ...
 */
std::string color_to_hex(
    const Color& c, 
    std::string prefix, 
    bool uppercase
) {
    // ...
}

Now, in the Doxygen-generated documentation, the default values of the parameters ("#" and false) do not appear.

I have tried:

  • Use the @param tag. Doesn't work, no default param values appear.
  • Move the doc-block to the declaration. Works, but as mentioned, not what I want.
  • Add a minimal doc-block to the declaration (/** */). Nothing happens.
  • Add an additional (different) doc-block to the header. As expected, the documentation now contains both texts, but no default values appear.
  • Add the identical doc-block to the declaration. Doxygen is smart enough to realize this and only outputs the text once. However, no default param values.

Any ideas on how to get this to work?

luc
  • 322
  • 1
  • 15
  • 3
    Documentation should be done in the header files primarily for numbers of good reasons. – πάντα ῥεῖ Mar 09 '16 at 14:37
  • Could you please name those reasons or provide a link? Otherwise, your comment is little helpful. [Here is a comparison of both ways](http://programmers.stackexchange.com/questions/84071/is-it-better-to-document-functions-in-the-header-file-or-the-source-file). – luc Mar 09 '16 at 16:07
  • [Here's](http://stackoverflow.com/questions/487114/c-c-header-file-documentation) some more input. – πάντα ῥεῖ Mar 09 '16 at 16:13
  • Thanks! One common suggestion seems to be to put the API doc next to the declaration and the implementation doc next to the definition. Seems reasonable. If I do that, however, I still have the problem of disappearing default parameter values. In short: any idea on the actual question? – luc Mar 09 '16 at 23:06

0 Answers0