Doxygen - Document a struct variable but not the struct
I've found a way to do it. Using proprocessor predefines as @RBE suggested lets you create code only for doxygen which won't compile anyway. So just do this (and make DOXYGEN
a predefined macro):
typedef struct Hidden Hidden;
#ifdef DOXYGEN
struct
{
int foo; ///< Number of particals in the universe.
int bar; ///< Number of socks in the drawer.
} visible; ///< Nameless struct variable!
#endif
struct Hidden
{
int foo;
int bar;
};
Hidden visible;
It's hacky, but it works.
Avidan Borisov
Updated on September 24, 2022Comments
-
Avidan Borisov almost 2 years
Let's say I have this struct type:
typedef struct Hidden Hidden; struct Hidden { int foo; int bar; };
and then I have a global variable
Hidden visible;
Hidden
should never be used andvisible
should be the only declaration of typeHidden
. I don't want to generate documentation forHidden
as I don't want it to be used, but instead generate documentation forvisible
with all the information about it and about its fields.The closest thing I've found is that when you document a
struct
with no tag like:struct { int foo; ///< Number of particals in the universe. int bar; ///< Number of socks in the drawer. } Baz; ///< Nameless struct variable.
Doxygen will generate
struct { int foo Number of particals in the universe. int bar Number of socks in the drawer. } Baz Nameless struct variable.
This is the sort of thing I'm trying to achieve, but I can't use nameless structs.
Is such thing possible?
-
Avidan Borisov over 11 yearsYou misunderstood me. I don't want to just change the name of the structure from HIDDEN to VISIBLE. I want to generate documentation just to a single struct variable instead of documentation for the struct type itself.
-
rbaleksandar over 7 yearsJust a note here - it is strongly recommended not to leave undocumented parts of your API especially if the contents of the undocumented functions/enums/structs/etc. are actually documented.