C# Doxygen:隐藏私有/受保护的方法......和提示
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/562763/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Doxygen: hiding private/protected method...and tips
提问by
I am using Doxygen to generate documentation for our API, written in C#. However, it exposes private/protected members. Is there a way to hide those?
我正在使用 Doxygen 为我们的 API 生成文档,用 C# 编写。但是,它公开了私有/受保护的成员。有没有办法隐藏这些?
I figured out how to hide files: EXCLUDE = List of file names
我想出了如何隐藏文件:排除 = 文件名列表
Yet, I need more granularity and thus shield users from unnecessary API noise. A sample Doxygen file would be appreciated as well as tips/tricks.
然而,我需要更多的粒度,从而保护用户免受不必要的 API 噪音的影响。示例 Doxygen 文件以及提示/技巧将不胜感激。
What tools do you use to generate API from the source code?
您使用什么工具从源代码生成 API?
I feel somewhat left in the 18th century as I use Doxygen in C# by way of C++.
当我通过 C++ 在 C# 中使用 Doxygen 时,我觉得有些离开了 18 世纪。
采纳答案by mouviciel
I don't know how well C# is supported by Doxygen.
我不知道 Doxygen 对 C# 的支持程度如何。
For hiding private members, you change Doxyfile
configuration file as following:
要隐藏私有成员,您Doxyfile
可以按如下方式更改配置文件:
EXTRACT_PRIVATE = YES
Many other options can be set for various kinds of extracting/hiding code elements, e.g., citing Doxyfile
itself:
可以为各种提取/隐藏代码元素设置许多其他选项,例如,引用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
回答by éric Malenfant
A few possibilities, from the doxygen manual:
一些可能性,来自doxygen 手册:
HIDE_UNDOC_MEMBERS
, HIDE_UNDOC_CLASSES
: Obviously works only if you only document the public members.
HIDE_UNDOC_MEMBERS
, HIDE_UNDOC_CLASSES
: 显然只有当你只记录公共成员时才有效。
INTERNAL_DOCS
: Allows you to use the \internal markup to exclude comments from the "public" version of the documentation.
INTERNAL_DOCS
: 允许您使用 \internal 标记从文档的“公共”版本中排除注释。
ENABLED_SECTIONS
: Are more general version of INTERNAL_DOCS
ENABLED_SECTIONS
: 是更一般的版本 INTERNAL_DOCS
回答by james
Check out the @cond flag for doxygen. In C# I hide some of our password encryption members like this:
查看 doxygen 的 @cond 标志。在 C# 中,我隐藏了一些密码加密成员,如下所示:
//! @cond
private const String ENCRYPTEDFLAG = "xxxENCFLAGxxx";
private const String SEED = "hi_i_r_@_seed";
//! @endcond
The doxygen documentation would have you believe that you need a conditional symbol defined to doxygen and used on the @cond line, but that did not work for me. This method did.
doxygen 文档会让您相信您需要一个为 doxygen 定义并在 @cond 行上使用的条件符号,但这对我不起作用。这个方法做到了。
回答by djromero
This works for me, to hide big chunks of code and documentation:
这对我有用,可以隐藏大量代码和文档:
/*! \cond PRIVATE */
<here goes private documented source code>
/*! \endcond */
Run with ENABLED_SECTIONS = PRIVATE
to create your internal version of the docs. You can have several conditions and enable/disable them according to the audience.
运行ENABLED_SECTIONS = PRIVATE
以创建文档的内部版本。您可以设置多个条件并根据受众启用/禁用它们。
To hide just part of a documentation block, use \internal
(will hide until the end of the block unless \endinternal
is found)
要仅隐藏文档块的一部分,请使用\internal
(除非\endinternal
找到,否则将隐藏到块的末尾)
Note: you can use @ notation if you prefer it over backslashes.
注意:如果你更喜欢 @ 符号而不是反斜杠,你可以使用 @ 符号。