13

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

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

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

4

6 回答 6

10

附加到 Mac H 的答案,您必须设置这些额外的配置参数才能使其工作:

# 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
于 2011-07-15T09:33:17.280 回答
5

这是一个旧条目,但我遇到了同样的问题。

一种对我有用的方法是简单地使用 doxygen 的“预定义”功能。如果您预定义了“internal=private”(相当于执行“#define internal private”),那么 Doxygen 会将所有“内部”属性视为“私有”——因此如果需要,请忽略它们。

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

于 2011-06-09T09:06:33.260 回答
1

刚刚遇到这个话题...使用 \internal doxygen 关键字,它就是为此而设计的。

于 2011-11-21T13:34:46.563 回答
1

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

如果您的方法是私有的,则设置EXTRACT_PRIVATE = NO

您还可以指定排除模式,例如,如果您的私有类位于名为 hidden 的目录中,您可以通过设置排除该目录中的所有文件。

EXCLUDE_PATTERNS = */hidden/* 

您还可以通过设置避免包含未记录的代码。

HIDE_UNDOC_CLASSES = YES

HIDE_UNDOC_MEMBERS = NO
于 2009-12-07T19:41:38.033 回答
0

环境

HIDE_UNDOC_CLASSES = YES

EXTRACT_PRIVATE对我有用,即使使用PREDEFINED默认值也是如此。不确定原因。我希望它们需要设置NO(因此没有可用于私有成员的文档)和internal=private(因此文档也从内部类中删除),但事实并非如此。internalprivate类在生成的文档中不再提及。

于 2014-01-29T09:31:57.777 回答
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 完全按照您希望的方式处理上面的源代码:仅记录了显式公共类和结构,没有提及显式或隐式内部类或结构。)

于 2017-09-12T14:51:31.933 回答