我正在使用Doxygen爲我正在處理的C#項目生成一些API文檔。我在這個項目中有相當多的「內部」功能,並且不希望Doxygen在生成的生成的html中生成這些簽名。Doxygen與C#內部訪問修飾符
我已經嘗試啓用HIDE_FRIEND_COMPOUNDS,但這仍然導致我的內部類在生成的文檔中公開。
有誰知道如何做到這一點?
我正在使用Doxygen爲我正在處理的C#項目生成一些API文檔。我在這個項目中有相當多的「內部」功能,並且不希望Doxygen在生成的生成的html中生成這些簽名。Doxygen與C#內部訪問修飾符
我已經嘗試啓用HIDE_FRIEND_COMPOUNDS,但這仍然導致我的內部類在生成的文檔中公開。
有誰知道如何做到這一點?
doxygen有幾種方法可以通過在配置文件中設置選項的方式從文檔中排除代碼。
如果你的方法是私人然後設置EXTRACT_PRIVATE = NO
您還可以指定要排除的模式,例如,如果你的私人類位於一個名爲隱藏的目錄,你可以通過設置排除在該目錄中的所有文件。
EXCLUDE_PATTERNS = */hidden/*
此外,您可以通過設置避免包括非文件化的代碼。
HIDE_UNDOC_CLASSES = YES
和
HIDE_UNDOC_MEMBERS = NO
這是一個古老的入口,但我有同樣的問題。
一個適用於我的方法是簡單地使用doxygen的'預定義'功能。 如果您預先定義了'internal = private'(相當於做一個'#define internal private'),那麼Doxygen會將所有'internal'屬性視爲'private' - 所以如果要求的話忽略它們。
這是一個kludge - 但它的工作原理。
附加組件到Mac轟的答案,你必須設置這些附加配置參數,使其工作:
# The PREDEFINED tag can be used to specify one or more macro names that
# are defined before the preprocessor is started (similar to the -D option of
# gcc).
PREDEFINED = internal=private
# If the EXTRACT_PRIVATE tag is set to YES all private members of a class
# will be included in the documentation.
EXTRACT_PRIVATE = NO
# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will
# evaluate all C-preprocessor directives found in the sources and include
# files.
ENABLE_PREPROCESSING = YES
# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro
# names in the source code. If set to NO (the default) only conditional
# compilation will be performed. Macro expansion can be done in a controlled
# way by setting EXPAND_ONLY_PREDEF to YES.
MACRO_EXPANSION = YES
# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES
# then the macro expansion is limited to the macros specified with the
# PREDEFINED and EXPAND_AS_DEFINED tags.
EXPAND_ONLY_PREDEF = YES
** RELATED **:顯然,Doxygen不會爲'public static'類生成一個頁面,除非您設置了'EXTRACT_STATIC = YES'。顯然,doxygen認爲'static'在C#中意味着它在C語言中的含義(即file-private),即使在C++中,doxygen的本地語言「靜態」通常也不是這個意思。出於某種原因,如果沒有這個選項,這些類仍然會在類列表中列出(帶有摘要),但從v1.8.7開始沒有鏈接(沒有生成類頁面)。 (P.S.哇,這些蟲至少4歲?!) – Qwertie 2014-07-07 00:59:15
整個話題就來了......用\內部doxygen的關鍵字,它只是設計用於。
設置
HIDE_UNDOC_CLASSES = YES
作品對我來說,即使在默認值EXTRACT_PRIVATE
和PREDEFINED
。不確定原因。我希望他們需要設置在NO
(所以沒有可用於私人成員的文檔)和internal=private
(所以文檔也從內部類中刪除),但事實並非如此。 internal
和private
類在生成的文檔中的任何地方都沒有提及。
Doxygen顯然認爲C#類和結構的默認值是公共的,而不是內部的,並且會將它們記錄下來。但是,如果您明確使用C#internal
訪問修飾符,則Doxygen尊重它(某種程度上),但如果您使用的是。所以,這個源上運行的Doxygen:
namespace Test_Library
{
/// <summary>
/// I should be documented.
/// </summary>
public class ExplicitPublicClass
{
public int Field;
}
/// <summary>
/// I should NOT be documented.
/// </summary>
class ImplicitInternalClass
{
public int Field;
}
/// <summary>
/// I should NOT be documented.
/// </summary>
internal class ExplicitInternalClass
{
public int Field;
}
/// <summary>
/// I should be documented.
/// </summary>
public struct ExplicitPublicStruct
{
public int Field;
}
/// <summary>
/// I should NOT be documented.
/// </summary>
struct ImplicitInternalStruct
{
public int Field;
}
/// <summary>
/// I should NOT be documented.
/// </summary>
internal struct ExplicitInternalStruct
{
public int Field;
}
}
讓你在使用Doxygen輸出此班級列表:
C ExplicitPublicClass I should be documented.
C ExplicitPublicStruct I should be documented.
C ImplicitInternalClass I should NOT be documented.
C ImplicitInternalStruct I should NOT be documented.
但是,你仍然得到明確的內部類和結構中的Doxygen的名單命名空間參考:「
class ExplicitInternalClass
I should NOT be documented.
struct ExplicitInternalStruct
I should NOT be documented.
class ExplicitPublicClass
I should be documented. More...
struct ExplicitPublicStruct
I should be documented. More...
class ImplicitInternalClass
I should NOT be documented. More...
struct ImplicitInternalStruct
I should NOT be documented. More...
但請注意」更多... 「鏈接到實際的文檔(以及相關的類/結構名稱中可用的鏈接)不可用於前兩個。
所以,你可以得到你通過使用C#的明確internal
訪問修飾符尋找一些行爲,但不一定你正在尋找的行爲的所有。 (通過比較,VSDocMan完全按照您希望的方式處理源代碼:只有明確的公共類和結構被記錄,沒有提及明確或隱含的內部類或結構。)
這些是C#內部類,它們與私有類不同。它們具有程序集範圍:只有同一個程序集內的其他代碼才能看到它們。我不希望這些類在文檔中可見,我只希望公共類可見。 – 2009-12-08 04:18:19