Doxygen 的 C++ 异常文档类运算符

发布于 2024-10-14 01:23:05 字数 967 浏览 5 评论 0原文

如果我的文件中有一个类,我无法更改,但我需要在 doxygen 中记录,最好的方法是什么?我知道最好在实际的 .h 或 .cpp 文件中进行记录,但在这个特定实例中,这是不可能的。

我已经弄清楚如何记录一些成员,但我无法以可靠的方式记录操作员。让我举个例子。这是一个示例类,其中一个成员引起了问题,而一个成员工作正常:

class Foo
{
public:
    int Bar();
    bool operator!() const;
};

在 doxygen 查看的其他一些文件中,我放置了以下内容:

/// @fn Foo::Bar
/// @brief Some info about the constructor
/// @return Some stuff about what bar returns

构造函数的文档有效,但这不起作用:

/// @fn Foo::operator!
/// @brief Some info about the operator
/// @return Some stuff about what the operator! returns

也没有:

/// @fn operator!
/// @memberof Foo
/// @brief Some info about the operator
/// @return Some stuff about what the operator! returns

我还尝试使用 % 和 转义各个部分。所以它看起来像“/// @fn %operator!”、“/// @fn operator%!”或“/// @fn 运算符!”但没有任何像这样的帮助。

有关运营商的信息永远不会显示。有几次我尝试将一个唯一值放入操作员 doxygen 注释中,并在 doxygen 输出中查找它,但结果是空的。我做错了什么?

If I have a class in a file I can't change, but I need to document in doxygen, what is the best way to do it? I know it would be best to document in the actual .h or .cpp file, but in this specific instance, that is not possible.

I have figured out how to document some members, but I cannot document operators in a reliable way. Let me provide an example. Here is an example class with a member that has caused problems and one that worked fine:

class Foo
{
public:
    int Bar();
    bool operator!() const;
};

In some other file that doxygen looks through, I have put the following:

/// @fn Foo::Bar
/// @brief Some info about the constructor
/// @return Some stuff about what bar returns

The documentation for the constructor works, but this doesn't:

/// @fn Foo::operator!
/// @brief Some info about the operator
/// @return Some stuff about what the operator! returns

neither does:

/// @fn operator!
/// @memberof Foo
/// @brief Some info about the operator
/// @return Some stuff about what the operator! returns

I have also tried escaping various parts with a % and . So it looked like "/// @fn %operator!", "/// @fn operator%!" or "/// @fn operator!" but nothing likes this has helped.

The Info about the operator never shows up. A few times I tried putting a unique value into the operator doxygen comments and grepping for it in the doxygen output and I came up empty. What am I doing wrong?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

风蛊 2024-10-21 01:23:05

如果您查看 doxygen 输出,应该会出现警告

/path/to/Documentation: warning: no matching class member found for
  Foo::operator!()
Possible candidates:
  bool Foo::operator!() const

,在这种情况下,请更改文档以

/// @fn Foo::operator!() const
/// @brief Some info about the operator
/// @return Some stuff about what the operator! returns

记下附加到 @fn 标识符的附加 () const

If you look at your doxygen output, there should be a warning

/path/to/Documentation: warning: no matching class member found for
  Foo::operator!()
Possible candidates:
  bool Foo::operator!() const

in which case, change your documentation to

/// @fn Foo::operator!() const
/// @brief Some info about the operator
/// @return Some stuff about what the operator! returns

note the additional () const appended to the @fn identifier.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文