2009-12-07 85 views
12

我正在使用Doxygen为我正在处理的C#项目生成一些API文档。我在这个项目中有相当多的“内部”功能,并且不希望Doxygen在生成的生成的html中生成这些签名。Doxygen与C#内部访问修饰符

我已经尝试启用HIDE_FRIEND_COMPOUNDS,但这仍然导致我的内部类在生成的文档中公开。

有谁知道如何做到这一点?

回答

1

doxygen有几种方法可以通过在配置文件中设置选项的方式从文档中排除代码。

如果你的方法是私人然后设置EXTRACT_PRIVATE = NO

您还可以指定要排除的模式,例如,如果你的私人类位于一个名为隐藏的目录,你可以通过设置排除在该目录中的所有文件。

EXCLUDE_PATTERNS = */hidden/* 

此外,您可以通过设置避免包括非文件化的代码。

HIDE_UNDOC_CLASSES = YES 

HIDE_UNDOC_MEMBERS = NO 
+0

这些是C#内部类,它们与私有类不同。它们具有程序集范围:只有同一个程序集内的其他代码才能看到它们。我不希望这些类在文档中可见,我只希望公共类可见。 – 2009-12-08 04:18:19

4

这是一个古老的入口,但我有同样的问题。

一个适用于我的方法是简单地使用doxygen的'预定义'功能。 如果您预先定义了'internal = private'(相当于做一个'#define internal private'),那么Doxygen会将所有'internal'属性视为'private' - 所以如果要求的话忽略它们。

这是一个kludge - 但它的工作原理。

9

附加组件到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 
+1

** 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

0

整个话题就来了......用\内部doxygen的关键字,它只是设计用于。

0

设置

HIDE_UNDOC_CLASSES = YES 

作品对我来说,即使在默认值EXTRACT_PRIVATEPREDEFINED。不确定原因。我希望他们需要设置在NO(所以没有可用于私人成员的文档)和internal=private(所以文档也从内部类中删除),但事实并非如此。 internalprivate类在生成的文档中的任何地方都没有提及。

0

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完全按照您希望的方式处理源代码:只有明确的公共类和结构被记录,没有提及明确或隐含的内部类或结构。)