我正在使用Doxygen为我们的API生成文档,用C#编写。但是,它暴露了私人/受保护的成员。有没有办法隐藏那些?
我想出了如何隐藏文件:EXCLUDE =文件名列表
然而,我需要更多的粒度,从而保护用户免受不必要的API噪音。一个示例Doxygen文件将被赞赏以及提示/技巧。
您使用哪些工具从源代码生成API?
我觉得有点遗留在18世纪,因为我在C#中通过C ++使用Doxygen。
答案 0 :(得分:20)
我不知道Doxygen支持C#的程度如何。
要隐藏私有成员,请按以下方式更改Doxyfile
配置文件:
EXTRACT_PRIVATE = YES
可以为各种提取/隐藏代码元素设置许多其他选项,例如引用Doxyfile
本身:
# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in
# documentation are documented, even if no documentation was available.
# Private class members and static file members will be hidden unless
# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES
EXTRACT_ALL = YES
# If the EXTRACT_PRIVATE tag is set to YES all private members of a class
# will be included in the documentation.
EXTRACT_PRIVATE = YES
# If the EXTRACT_STATIC tag is set to YES all static members of a file
# will be included in the documentation.
EXTRACT_STATIC = YES
# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs)
# defined locally in source files will be included in the documentation.
# If set to NO only classes defined in header files are included.
EXTRACT_LOCAL_CLASSES = YES
# This flag is only useful for Objective-C code. When set to YES local
# methods, which are defined in the implementation section but not in
# the interface are included in the documentation.
# If set to NO (the default) only methods in the interface are included.
EXTRACT_LOCAL_METHODS = YES
# If this flag is set to YES, the members of anonymous namespaces will be
# extracted and appear in the documentation as a namespace called
# 'anonymous_namespace{file}', where file will be replaced with the base
# name of the file that contains the anonymous namespace. By default
# anonymous namespace are hidden.
EXTRACT_ANON_NSPACES = NO
# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all
# undocumented members of documented classes, files or namespaces.
# If set to NO (the default) these members will be included in the
# various overviews, but no documentation section is generated.
# This option has no effect if EXTRACT_ALL is enabled.
HIDE_UNDOC_MEMBERS = NO
# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all
# undocumented classes that are normally visible in the class hierarchy.
# If set to NO (the default) these classes will be included in the various
# overviews. This option has no effect if EXTRACT_ALL is enabled.
HIDE_UNDOC_CLASSES = NO
# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all
# friend (class|struct|union) declarations.
# If set to NO (the default) these declarations will be included in the
# documentation.
HIDE_FRIEND_COMPOUNDS = NO
答案 1 :(得分:13)
查看doxygen的@cond标志。在C#中,我隐藏了一些密码加密成员,如下所示:
//! @cond
private const String ENCRYPTEDFLAG = "xxxENCFLAGxxx";
private const String SEED = "hi_i_r_@_seed";
//! @endcond
doxygen文档会让你相信你需要一个定义为doxygen的条件符号并在@cond线上使用,但这对我不起作用。这种方法确实如此。
答案 2 :(得分:8)
这对我来说很有用,可以隐藏大量的代码和文档:
/*! \cond PRIVATE */
<here goes private documented source code>
/*! \endcond */
使用ENABLED_SECTIONS = PRIVATE
运行以创建文档的内部版本。您可以有多个条件,并根据受众启用/禁用它们。
要隐藏文档块的一部分,请使用\internal
(除非找到\endinternal
,否则将隐藏到块的末尾)
注意:如果您更喜欢反斜杠,可以使用@表示法。
答案 3 :(得分:3)
HIDE_UNDOC_MEMBERS
,HIDE_UNDOC_CLASSES
:显然只有在您只记录公众成员时才有效。
INTERNAL_DOCS
:允许您使用\ internal标记从文档的“公共”版本中排除注释。
ENABLED_SECTIONS
:是INTERNAL_DOCS