doxygenaliasesdoxygen-addtogroup

How to use \addtogroup with an ALIASES command?


I'm trying to create a custom command for easier group handling. The idea is in general...

ALIASES += opengroup{1}="^^* \addtogroup \1_GROUP ^^ * \{ ^^"
ALIASES += close="\}"

...to use in code file as...

/** \opengroup{LEVEL_1} */
// ...code statements...
/** \close */ // opengroup

...to get the doxygen result comment:

/**
* \addtogroup LEVEL_1_GROUP
* \{
*/
// ...code statements...
/** \} */ // opengroup

I tried with Doxygen 1.8.14. Unfortunately, this doesn't work. Any ideas?

Edit: I think the root problem is the \addtogroup command with its syntax. My hope was to clear this with inserting '^^' to force a new line, but it seems to me doxygen is parsing the command in one line instead of resolving the '^^' new line in a pre-step...


Solution

  • A bit weird. With the alias:

    ALIASES += opengroup{1}="^^* \addtogroup \1_GROUP ^^ * \\{ ^^"
    

    so with a double backslash (\\) before the curly bracket open ({) I got it working. I also get it working with:

    ALIASES += opengroup{1}="^^* \addtogroup \1_GROUP ^^ * @{ ^^"
    

    so it looks like the extra backslash is eaten at an unexpected place. The \ and @ should be synonyms, but as \ is also an escape character so it is quite often tricky.

    Note:

    1. I used doxygen -d commentscan to see the replacement
    2. Might change in the future as I think this might be a bug.
    3. Problem is caused due to the fact that ALIASES can be nested and after a change the new string is seen as input. When needing a literal {, } or , in the expanded output one has to escape them with a \ and the \ is removed at the en. Problem here arises with the commands \{ and \} as here the \ serves as 'command indicator'. Best to use @{ and @} in case the 'block commands' are needed. the \} in \close doesn't have the problem as it is not re-evaluated.