0

I have some code like the following example:

/** @file HelloPi.c */

/** The definition of pi */
#define PI 3.1415

/** @brief The main function.
 *  @details Prints the value of #PI, which is actual defined as 3.1415. */
void main()
{
  printf("The value of pi is %f\n",PI);
}

In my doxygen dokumentation I would like to to have NO macro expansion for PI (and other defines) in general. But on one paragraph in the documentation I need the value of pi (e.g. @details description of the main function).

Is there any possibility to expand the macro at this single part of documentation with a command or something? Something like /** @details ...the value of #PI is $(PI).*/

I only know the build-in MACRO_EXPANSION tag which works for the whole documentation: https://www.doxygen.nl/manual/preprocessing.html :-/

Thanks for help :)
Jan

Edit: Add an other example which maybe better describes my Problem:

/** @file ErrorHandling.c */


#define ERR_CODE_POWERUNIT 1001 ///< Error in power unit */
            /** @page errors
             *  [value of ERR_CODE_POWERUNIT ] means \copybrief ERR_CODE_POWERUNIT */

void errHandler(int error)
{
  if(error=ERR_CODE_POWERUNIT)
    printf("Error %d occur\n",ERR_CODE_POWERUNIT);
}

In the documentation I would like to have: "1001 means Error in power unit"

Jan
  • 7
  • 2

1 Answers1

0

In doxygen there is no possibility to do a conversion of a predefined variable (only) in the documentation. You used in your documentation the an environment variable $(PI) but ths is quite cumbersome as you have to st the environment variable each time.

A better solution would be to use an ALIASES like:

ALIASES += pi=3.1415

or

ALIASES +\= "The value of PI = 3.14159265359..."

with which you define a command \pi that can be used in the documentation and will be replaced with the text / commands in the alias.

/** @details ...the value of #PI is \pi.*/

would result in something like (by head:

  ...the value of #PI is 3.1415
albert
  • 8,285
  • 3
  • 19
  • 32
  • Hi Albert, when I use the alias I always refer to the value in the config file and not to the one in the code. So I need to define my macro in source AND in the config. Another example: PI is not pi, but an error code which is shown to the user: In the code I have `#define POWER_ERROR 1001` and use the macro in the code. But the user only get the 1001. Would be great to get the documentation that 1001 means 'error in the power-unit'. – Jan Apr 23 '21 at 10:23
  • Indeed I forgot to mention that you have to double the information (I thought about it but forgot to write it down). I don't get the second part of the comment yet, the text 'error in the power-unit' must be available as well, , so why not adding it to the ALIASES as well like `ALIASES += err_1001="1001 i.e. error in the power unit"` or `ALIASES += err_1001="error in the power unit"` and use in the documentation `\err_1001` – albert Apr 23 '21 at 11:07
  • Yes would be an possibility. Anyway you need to write it twice. Once in code once somewehere else. I think I will go the following way: ``` /** @page errors 1001 means \copybrief ERR_CODE_POWERUNIT */ ``` (example above). everything is at one place / file.The only thing to do is writing '1001' per hand into the doc page. So copy&paste for other error codes will need a little bit of attention :) but other developers don't need to look in different files. Maybe the easiest way. – Jan Apr 23 '21 at 13:38
  • Thank you for helping, Albert! :) – Jan Apr 23 '21 at 13:39
  • The solution with copybrief for the text looks quite valid. Thinking about it qyou might also be successful wilt `ALIASES +="ERR{1}="\1 means \copybrief ERR_CODE_\1` and use in the docu: `\ERR{1001}` – albert Apr 23 '21 at 14:37
  • Seems to be a good way! Thank you very much for the quick support! I marked this post as the preferred answer. – Jan Apr 26 '21 at 06:58