2013-03-07 45 views
2

比方說,我有這樣的結構類型:的Doxygen - 文檔結構變量而不是結構

typedef struct Hidden Hidden; 
struct Hidden 
{ 
    int foo; 
    int bar; 
}; 

,然後我有一個全局變量

Hidden visible; 

Hidden不應該被用來和visible應成爲Hidden類型的唯一聲明。我不想爲Hidden生成文檔,因爲我不希望它被使用,而是生成關於visible的文檔以及關於它的所有信息及其字段。

我發現的最接近的是,當你有沒有像標籤記錄一個struct

struct 
{ 
    int foo; ///< Number of particals in the universe. 
    int bar; ///< Number of socks in the drawer. 
} Baz; ///< Nameless struct variable. 

的Doxygen將產生

struct { 
    int foo 
     Number of particals in the universe. 
    int bar 
     Number of socks in the drawer. 
} Baz 
    Nameless struct variable. 

這是我想要的那種東西實現,但我不能使用無名的結構。

這樣的事情可能嗎?

回答

1

我找到了一種方法來做到這一點。建議使用proprocessor預定義,因爲建議使用@RBE,您可以僅爲不會編譯的doxygen創建代碼。因此,只要做到這一點(並DOXYGEN預定義宏):

typedef struct Hidden Hidden; 

#ifdef DOXYGEN 

struct 
{ 
    int foo; ///< Number of particals in the universe. 
    int bar; ///< Number of socks in the drawer. 
} visible; ///< Nameless struct variable! 

#endif 

struct Hidden 
{ 
    int foo; 
    int bar; 
}; 

Hidden visible; 

這是哈克,但它的作品。

+0

這裏只是一個註釋 - 強烈建議不要留下API的無證部分,特別是如果未記錄的函數/枚舉/結構體等的內容。實際上記錄在案。 – rbaleksandar 2017-02-16 13:13:54

0

做你想要什麼,最簡單的方法是使用宏定義,你會編譯代碼之間切換,並且你的代碼將在運行doxygen的:

#define DOXYGEN 

#ifdef DOXYGEN 
/** 
* @brief Describe your visible structure here. 
*/ 
typedef struct VISIBLE 
{ 
    int foo; //< Number of particles in the universe. 
    int bar; //< Number of socks in the drawer. 
} VISIBLE; 
#else 
typedef struct HIDDEN 
{ 
    int foo; 
    int bar; 
} HIDDEN; 

HIDDEN visible; 
#endif 

簡單的評論或取消對DOXYGEN定義從一個切換到另一個。

+0

描述你誤解了我。我不想只將結構的名稱從HIDDEN改爲VISIBLE。我只想爲單個結構體變量生成文檔,而不是爲結構體類型本身生成文檔。 – 2013-03-07 20:33:17