JohnLXiang
JohnLXiang

Reputation: 178

Doxygen documentation for enum class in a seperate header

I was trying to add documentation for an enum class which resides in its own header file. Below is what I have done so far

/**
@file
*/
namespace foo {

/**
@brief blablabla
*/
enum class MyEnum{
    /**
     This is ENUM_A
    */
    ENUM_A,
    /**
     This is ENUM_B
    */
    ENUM_B,
    /**
     This is ENUM_C
    */
    ENUM_C
};
}

For some reason, the generated doc shows these 3 enum members in the list, but when I click them, it doesn't generate the page that has their own description. However this worked when I put this enum class in another class. Could any one help me to spot what I have been missing? Thanks.

Upvotes: 2

Views: 1887

Answers (1)

BobMorane
BobMorane

Reputation: 4296

From the Doxygen documentation:

To document a member of a C++ class, you must also document the class itself. The same holds for namespaces. To document a global C function, typedef, enum or preprocessor definition you must first document the file that contains it (usually this will be a header file, because that file contains the information that is exported to other source files).

So if you document your foo namespace, everything works fine:

/**
@brief Namespace foo
*/
namespace foo {

/**
@brief My enum
*/
enum class MyEnum{
    /**
     This is ENUM_A
    */
    ENUM_A,
    /**
     This is ENUM_B
    */
    ENUM_B,
    /**
     This is ENUM_C
    */
    ENUM_C
};
}

First click on Namespace, then foo and then your enum documentation is available.

UPDATE


As @albert pointed out, there is an alternative way. According to the Doxygen documentation,

If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in documentation are documented, even if no documentation was available. Private class members and static file members will be hidden unless the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES

This is a nice option if you have many such scenarios in your codebase.

Upvotes: 2

Related Questions