开发者

Doxygen Out of Line Documenting for C++ Class Operators

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开发者_如何学C 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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜