Expand non-function macros in doxygen documentatio

2020-04-20 22:19发布

问题:

I am trying to document my C code using doxygen. I have some default values set as macros with #define. (I know C does not have default values but this is just an example)

e.g.:

#define DEFAULT_WIDTH  100
#define DEFAULT_HEIGHT 200

Inside doxygen I have added an alias that handles default values in the way I want. Consider the example function below

//! Initializes something
//! @param width The width @default DEFAULT_WIDTH
//! @param height The height @default DEFAULT_HEIGHT
//! @return Result of initialization
char initSomething(int width,int height);

This will generate the documentation as I want it except one important fact. DEFAULT_WIDTH and DEFAULT_HEIGHT do not get expanded , I get the macro names and not 100 and 200 respectively. I do have MACRO_EXPANSION and ENABLE_PREPROCESSING checked on.

What am I missing? Is there actually any way to achieve this using doxygen?

I am configuring doxygen with doxywizard and I am currently testing under Windows.

EDIT: As ugoren points out it is possible to just document the macro and then doxygen will link that documentation to them. This is how my current implementation is in my project actually. But I am trying to consider additional options - if any exist.

回答1:

I don't think there's anything stronger than MACRO_EXPANSION and ENABLE_PREPROCESSING.
The problem is probably that macros in comments are normally not expanded. There's a good reason for it - imagine the macro max expanded inside the documentation.

You can document the macro, so readers of the documentation would be able to find the real value easily.



回答2:

Add something like

EXPAND_AS_DEFINED += DEFAULT_WIDTH

to your doxygen configuration file.

(The documentation of P99 is full of such macro expansions. Its doxygen configuration file should come with the distribution.)



标签: c doxygen