使用 Doxygen 用 C++ 记录宏函数
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4542626/
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 Macro Functions in C++ with Doxygen
提问by rcv
How do I document a macro function in C++ using Doxygen, and refer to it in the documentation of my non-Evil code?
如何使用 Doxygen 在 C++ 中记录宏函数,并在非 Evil 代码的文档中引用它?
More specifically, I have some regular class called "Message" defined in Message.H that users can inherit from to define their own messages. In another file ("MessageHelpers.H") I have a crazy macro like this:
更具体地说,我在 Message.H 中定义了一些名为“Message”的常规类,用户可以从中继承以定义自己的消息。在另一个文件(“MessageHelpers.H”)中,我有一个像这样的疯狂宏:
//! Users must call this macro to register their messages...
/*!
...lest they be forced to type all sorts of boring and
error-prone boiler plate code.
blah blah blah... More specific documentation and explanation...
*/
#define REGISTER_MESSAGE_TYPE(MSGTYPE) \
do_some(MSGTYPE); \
seriously(); \
crazy_stuff(MSGTYPE);
In the documentation for Message, I would love it if the phrase "REGISTER_MESSAGE_TYPE" could automatically become a link and point to my documentation for the macro. E.g.
在 Message 的文档中,如果短语“REGISTER_MESSAGE_TYPE”可以自动成为链接并指向我的宏文档,我会很高兴。例如
//! A cool message class
/*!
Users can inherit from this class to create their own cool messages.
Just be sure to call REGISTER_MESSAGE_TYPE after your class definition!
*/
class Message
{
virtual void doSomeStuff();
};
Is this possible?
这可能吗?
采纳答案by Guerrero
See http://www.doxygen.nl/manual/index.html
见http://www.doxygen.nl/manual/index.html
The section "Special Commands"lists the \def
command, and the section "Automatic link generation"describes what you want to link to the macro.
该部分“特殊命令”列表中的\def
命令,以及部分“自动链接生成”描述要链接到宏观的东西。
Use \def
to document a macro separate from the declaration.
Use #MACRO(params)
to auto-link to said macro definition.
使用\def
记录的报关宏分开。
使用#MACRO(params)
自动链接到所述宏定义。