我注意到当默认构造函数不带参数时,Doxygen 可以链接来自实例的成员函数调用,但当构造函数带参数时无法链接它们。
- 这是为什么?
- 是否有在
@code
/@endcode
block 中手动添加链接的解决方法?
在下面的例子中:
t.foo()
-foo()
已链接u.foo()
-foo()
未链接
.
/** @file doxy.cpp */
/** struct T */
struct T {
/** foo */
void foo() { }
};
/** struct U */
struct U {
int a; /**< int a */
/** U */
U(int a_) : a(a_) { }
/** foo */
void foo() { }
};
/**
* main
*
* @code
* T t;
* t.foo(); // foo is linked
*
* U u(42);
* u.foo(); // foo is not linked
* @endcode
*/
int main()
{
return 0;
}
最佳答案
我认为这是 Doxygen 中已知问题的征兆。来自 http://www.doxygen.nl/manual/trouble.html
Redundant braces can confuse doxygen in some cases. For example:
void f (int);
is properly parsed as a function declaration, but
const int (a);
is also seen as a function declaration with name int, because only the syntax is analyzed, not the semantics. If the redundant braces can be detected, as in
int *(a[20]);
then doxygen will remove the braces and correctly parse the result.
所以在这种情况下,我相信:
U u(42);
被解释为函数而不是变量声明。
不幸的是,我不知道有任何选项可以在代码块中显式添加链接。我发现的唯一解决方法是重构代码,使声明看起来不像 Doxygen 的函数。例如,将您的变量初始化更改为:
U u = U(42);
允许 Doxygen 将 u
识别为变量而不是函数。
关于c++ - Doxygen `@code` block 中的链接有时会丢失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13048483/