Doxygen无证字符串值

时间:2017-01-13 19:13:27

标签: c++ doxygen

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

#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.

如果我将结构减少为单个成员并删除&#34; secondVal&#34;从初始化器开始,然后警告消失了,但显然这不是解决方案......

2 个答案:

答案 0 :(得分:3)

只需删除额外的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。

答案 1 :(得分:-1)

尝试将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.

BTW还有一个提示:

不要对多行实体使用///<条评论。如果您以这种方式评论您的代码,您的文档结果会更好:

/**
 * 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