2011-01-24 35 views
3

如果我在一個文件中有一個類,我不能更改,但是我需要在doxygen中創建文檔,那麼執行它的最佳方法是什麼?我知道最好在實際的.h或.cpp文件中記錄文件,但在這個特定的實例中,這是不可能的。Doxygen爲C++類運算符進行非實時記錄

我已經想出瞭如何記錄一些成員,但我不能以可靠的方式記錄操作符。讓我舉個例子。下面是一個成員的示例類已導致該工作的罰款問題和一個:

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註釋和grepping添加一個獨特的值,並且我空了。我究竟做錯了什麼?

回答

6

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

注意額外() const追加到@fn標識符。

+0

使用這種語法效果很好! – Sqeaky 2011-01-24 04:35:19