views:

2529

answers:

4

Hello,

I am using doxygen to generate documentation for our API, written in csharp. However, it exposes private/protected members. Is there a way to hide those?

I fugured out how to hide files: EXCLUDE = List of file names

Yet, I need more granularity and thus shield users from unnecessery API noise. A sample dyxygen file would be appreciated as well as tips/tricks.

What tools do you use to generate API from the source code?

I feel somewhat left in 18th century as I use doxygen in csharp by way of c++.

Thanks a lot.

Sasha

+1  A: 

I don't know how well C# is supported by Doxygen.

For hiding private members, you change Doxyfile configuration file as following:

EXTRACT_PRIVATE        = YES

Many other options can be set for various kinds of extracting/hiding code elements, e.g., citing Doxyfile itself:

# 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
mouviciel
A: 

A few possibilities, from the Doxygen manual:

HIDE_UNDOC_MEMBERS, HIDE_UNDOC_CLASSES: Obviously works only if you only document the public members.

INTERNAL_DOCS: Allows you to use the \internal markup to exclude comments from the "public" version of the documentation.

ENABLED_SECTIONS: Are more general version of INTERNAL_DOCS

Éric Malenfant
+2  A: 

Check out the @cond flag for doxygen. In C# I hide some of our password encryption members like this:

    //! @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.

james
A: 

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.

To hide just part of a documentation block, use \internal (will hide until the end of the block unless \endinternal is found)


Note: you can use @ notation if you prefer it over backslashes.

madmw