【问题标题】:Doxygen Out of Line Documenting for C++ Class OperatorsC++ 类运算符的 Doxygen 离线文档
【发布时间】:2011-06-14 06:35:09
【问题描述】:

如果我无法更改文件中有一个类,但我需要在 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 cmets 中输入一个唯一值,并在 doxygen 输出中对其进行 grepping,但结果是空的。我做错了什么?

【问题讨论】:

    标签: c++ doxygen


    【解决方案1】:

    如果你查看你的 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

    【讨论】:

    • 我也没有注意到我的 doxygen 输出中的警告,因为这个文件有大约 1200 个未记录的项目。一个完整的 API 定义就在那里。
    • 关闭未记录项目的警告。您仍然应该收到上述警告,因为这是另一种错误。
    猜你喜欢
    • 2015-01-14
    • 2023-04-07
    • 1970-01-01
    • 2011-03-27
    • 1970-01-01
    • 2021-02-04
    • 2011-02-25
    • 2013-08-17
    相关资源
    最近更新 更多