C++ 使用 doxygen 记录枚举值
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13752191/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Documenting enum values with doxygen
提问by Corey Richardson
Given:
鉴于:
namespace Foo {
class Foo {
public:
/// Foo enum, possible ways to foo
enum class Foo {
/// Foo it with an A
A,
/// Foo it with a B
B,
/// Foo it with a C
C
}
}
}
And the default Doxyfile made with doxygen -g
, I get this:
和使用 制作的默认 Doxyfile doxygen -g
,我得到了这个:
How can I get the enum values documented? I tried putting the comment before/after the member, using ///<
, etc, to no avail. Might this just be a bug in doxygen? The examples in the docs work. (Clicking on the name of the enum doesn't bring me anywhere)
如何记录枚举值?我尝试将评论放在成员之前/之后,使用///<
等,但无济于事。这可能只是 doxygen 中的一个错误吗?文档中的示例有效。(单击枚举的名称不会将我带到任何地方)
回答by Masked Man
With Doxygen 1.8.2, both the following work for me:
使用 Doxygen 1.8.2,以下两项都对我有用:
Using ///
使用 ///
/// This is an enum class
enum class fooenum {
FOO, ///< this is foo
BAR, ///< this is bar
};
Using /*! ... */
使用 /*! ... */
/*! This is an enum class */
enum class fooenum {
FOO, /*!< this is foo */
BAR, /*!< this is bar */
};
The doxygen changelogsays that enum class
is supported in Doxygen 1.8.2, so I suspect there may be some minor syntax issue in your commands. Could you please compare your commands with the above two snippets?
该doxygen的更新日志说,enum class
在Doxygen的1.8.2的支持,所以我怀疑可能有一些小的语法问题你的命令。您能否将您的命令与上述两个片段进行比较?
New features
Added support for C++11:
strongly typed enums, e.g.: enum class E
新功能
添加了对 C++11 的支持:
strongly typed enums, e.g.: enum class E
回答by Alexis Wilke
Note that I personally hate to have header files that go at length (because documenting means writing at least 2 or 3 lines of documentations, not one word so I generally don't have enough with the brief) so I prefer to document in the .cpp file.
请注意,我个人讨厌拥有冗长的头文件(因为记录意味着编写至少 2 或 3 行文档,而不是一个词,所以我通常对摘要不够用)所以我更喜欢在 . .cpp 文件。
To do that you use the \var
feature of Doxygen.
为此,您可以使用\var
Doxygen的功能。
So the header comes bare:
所以标题是裸露的:
namespace Foo {
class Foo {
public:
enum class Foo {
A,
B,
C
};
};
}
And the .cpp file has:
.cpp 文件有:
namespace Foo {
/** \enum Foo::Foo
* \brief Foo enum, possible ways to foo
*
* All the necessary details about this enumeration.
*/
/** \var Foo::A
* \brief Foo it with an A
*
* When you use A... etc.
*/
/** \var Foo::B
* \brief Foo it with a B
*
* When you use B... etc.
*/
/** \var Foo::C
* \brief Foo it with a C
*
* When you use C... etc.
*/
}
That way, I can really document at length which happens often to me.
这样,我可以真正详细地记录经常发生在我身上的事情。
回答by Ramón J Romero y Vigil
The below style works for me:
以下样式对我有用:
enum class Foo {
/**Foo it with A*/
A,
/**Foo it with B*/
B
}