Doxygen 未记录的字符串值

Doxygen undocumented string value

Doxygen (1.8.10) 抱怨我的字符串的 value 没有记录。这是一个演示问题的最小示例

#include <string>

struct MyStruct ///< Docs for struct
{
    std::string a; ///< Docs for a
    std::string b; ///< Docs for b
};

class MyClass ///< Docs for class
{
    static struct MyStruct instance; ///< Docs for instance
};

struct MyStruct MyClass::instance = {"firstVal", "secondVal"};

这会导致警告

/tmp/example.cpp:10: warning: Member firstVal (variable) of class MyClass is not documented.

如果我将结构缩减为单个成员并从初始化程序中删除 "secondVal",则警告消失,但显然这不是解决方案...

尝试将 doxyfile 中的 EXTRACT_ALL 标签设置为 YES,然后警告应该会消失。

还要注意 EXTRACT_ALL 设置的注释:

# 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 respectively EXTRACT_STATIC tags are set to YES.
# Note: This will also disable the warnings about undocumented members that are
# normally produced when WARNINGS is set to YES.
# The default value is: NO.

顺便提一句:

不要对 multi-line 个实体使用 ///< 评论。如果您这样注释代码,文档的结果会更好看:

/**
 * Docs for struct
 */
struct MyStruct 
{
    std::string a; ///< Docs for a
    std::string b; ///< Docs for b
};

/** 
 * Docs for class
 */
class MyClass 
{
    static struct MyStruct instance; ///< Docs for instance
};

否则,如果要使用///<注释,则必须将注释放在声明的分号之后:

struct MyStruct 
{
    std::string a; ///< Docs for a
    std::string b; ///< Docs for b
}; ///< Docs for struct

class MyClass 
{
    static struct MyStruct instance; ///< Docs for instance
}; ///< Docs for class

只需删除多余的 struct。如:

#include <string>

struct MyStruct ///< Docs for struct
{
    std::string a; ///< Docs for a
    std::string b; ///< Docs for b
};

class MyClass ///< Docs for class
{
    static struct MyStruct instance; ///< Docs for instance
};

MyStruct MyClass::instance = {"firstVal", "secondVal"};

C++ 不要求您使用 struct MyStruct,而是允许您使用普通的 MyStruct。进行这个微小的更改会使警告随 doxygen 1.8.13 一起消失。