Adding Header File Contents to Group Removes Content From Files - c++

I defined the following group in Doxygen:
/**
* #file CommandHandler.hpp
*/
#ifndef COMMAND_HANDLER_HPP
#define COMMAND_HANDLER_HPP
/**
* #defgroup CommandHandlers Command Handlers
*/
class CommandHandler
{
public:
...
Then I used the following to add the contents of a header file to the group:
/**
* #file GetSystemStatistics.hpp
*/
#ifndef GET_SYSTEM_STATISTICS_HPP_
#define GET_SYSTEM_STATISTICS_HPP_
#include "CommandHandler.hpp"
/** #addtogroup CommandHandlers */
/*#{*/
class GetSystemStatistics : public CommandHandler
{
public:
...
/*#}*/
The documentation from the header file appears in the Modules -> Command Handlers section as I expected, but the documentation is now gone from the Files -> File List -> header.hpp section.
Is there a way I can configure Doxygen so that the documentation from the header file appears in both places (i.e. under Modules and Files)? Is it a problem that I included a class definition in the header file that defines the group? I placed the #defgroup in CommandHandler.hpp because it was a common header file for all derived classes that belong to the group.

Related

Adding a function to multiple groups in doxygen

I am trying to add a function to multiple groups but it does not seems to be working.
I followed the instructions from here
Here are the comments I added:
/**
* \defgroup version1 version 1
*/
/**
* \defgroup version2 version 2
*/
/**
* \ingroup version1 version2
*/
BOOL CLoginFormDlg::OnInitDialog(){}
The function only appears in the version2 module and not in the version1 module.
if I write version1 last like this:
/**
* \ingroup version2 version1
*/
BOOL CLoginFormDlg::OnInitDialog(){}
then the function only appears in the version1 module and not the version2 module.
I would like them to appear in both modules
The link you provided includes a paragraph that explains why it doesn't work:
Note that compound entities (like classes, files and namespaces) can be put into multiple groups, but members (like variable, functions, typedefs and enums) can only be a member of one group (this restriction is in place to avoid ambiguous linking targets in case a member is not documented in the context of its class, namespace or file, but only visible as part of a group).
One approach to consider to solve this problem might be to create different Doxygen projects for each version of your code. You would create a Doxyfile for each version.
In this case, instead of trying to include common code in both sets of documentation using the \ingroup command, you would be excluding unrelated code from each set using conditional sections delimited by either \if...\endif or \cond...\endcond.
So in your version1 module, you would do the following:
/**
* \if _VERSION1_
*/
<all code in your version1 module>
/**
* \endif
*/
and in your version2 module:
/**
* \if _VERSION2_
*/
<all code in your version2 module>
/**
* \endif
*/
Code that needs to appear in both modules, such as your BOOL CLoginFormDlg::OnInitDialog(){} function, would have no such conditional commands, so would be included in both sets of documentation.
In your version1 Doxyfile, add the following line:
ENABLED_SECTIONS = _VERSION1_
and in your version2 Doxyfile:
ENABLED_SECTIONS = _VERSION2_
To link your version1 and version2 documentation sets together, you can use Doxygen's tag file mechanism.
See also
\cond
\if
ENABLED_SECTIONS
Tag files

DoxyGen ignores functions

I have a file like:
/** #file some description */
void SomeFunc();///< brief function description
The #file keyword is needed to document global functions, as per Doxygen mailing list. So here it is, but Doxygen keeps ignoring SomeFunc(), i.e. it doesn't appear anywhere in documentation.
The #file keyword is used to specify the file name, not the description. Try something like this:
//!
//! #file filename.h
//! #brief some description
//!

Documenting namespaces that span multiple files doxygen

Consider I have 2 header files.
// HEADER 1
/**
* Doc for Foo here?
*/
namespace Foo {
class This {...};
}
&&
// HEADER 2
/**
* Doc for Foo here?
*/
namespace Foo {
class That {...};
}
How should I handle this when documenting with Doxygen?
Maybe neither.
For example, imagine you have "<root>/utility/header1.hpp" which has its contents in namespace utility and "<root>/utility/header2.hpp" which does also.
You could add a file: "<root>/utility.hpp" which documents the utility namespace. You could put this at the top #error Documentation only. to make sure it's not accidentally included.
But I would recommend at least making some out-of-the-way file to keep it in a sane place (and not mixed in randomly with some class.)
I have placed documentation for namespaces that span multiple files into another file. My Doxygen builds use a separate file for the #mainpage tag. This forms the root of the built Doxygen, and is also a central location for such namespaces.
So I'll have project_name_mainpage.h, and in that file:
/**
#mainpage title
...whatever you want to tell the user about your application...
*/
/**
* #namespace your_namespace
* #brief An awesome description
* #details More sweet details
*/
Keeps it all in one place, and is relatively easy to find if you need to update it.
Find the best place for the documentation, whether it is in one of those files or another entirely. Use a comment block with Doxygen's namespace tag:
/**
* #namespace Foo
* Documentation for Foo here. More docs for Foo here,
* and down here.
*/
Docs here: http://www.doxygen.nl/manual/commands.html#cmdnamespace

Documenting preprocessor defines in Doxygen

Is it possible to document preprocessor defines in Doxygen? I expected to be able to do it just like a variable or function, however the Doxygen output appears to have "lost" the documentation for the define, and does not contain the define itself either.
I tried the following
/**My Preprocessor Macro.*/
#define TEST_DEFINE(x) (x*x)
and
/**#def TEST_DEFINE
My Preprocessor Macro.
*/
#define TEST_DEFINE(x) (x*x)
I also tried putting them within a group (tried defgroup, addtogroup and ingroup) rather than just at the "file scope" however that had no effect either (although other items in the group were documented as intended).
I looked through the various Doxygen options, but couldn't see anything that would enable (or prevent) the documentation of defines.
Yes, it is possible. The Doxygen documentation says:
To document global objects (functions, typedefs, enum, macros, etc),
you must document the file in which they are defined. In other words,
there must at least be a
/*! \file */
or a
/** #file */
line in this file.
You can use #defgroup, #addtogroup, and #ingroup to put related items into the same module, even if they appear in separate files (see documentation here for details). Here's a minimal example that works for me (using Doxygen 1.6.3):
Doxyfile:
# Empty file.
Test.h:
/** #file */
/**My Preprocessor Macro.*/
#define TEST_DEFINE(x) (x*x)
/**
* #defgroup TEST_GROUP Test Group
*
* #{
*/
/** Test AAA documentation. */
#define TEST_AAA (1)
/** Test BBB documentation. */
#define TEST_BBB (2)
/** Test CCC documentation. */
#define TEST_CCC (3)
/** #} */
Foo.h:
/** #file */
/**
* #addtogroup TEST_GROUP
*
* #{
*/
/** #brief My Class. */
class Foo {
public:
void method();
};
/** #} */
Bar.h:
/** #file */
/**
* #ingroup TEST_GROUP
* My Function.
*/
void Bar();
In this case, the TEST_DEFINE documentation appears in the Test.h entry under the Files tab in the HTML output, and the TEST_AAA etc. definitions appear under Test Group in the Modules tab together with class Foo and function Bar.
One thing to note is that if you put the file name after the #file command, e.g:
/** #file Test.h */
then this must match the actual name of the file. If it doesn't, documentation for items in the file won't be generated.
An alternative solution, if you don't want to add #file commands, is to set EXTRACT_ALL = YES in your Doxyfile.
I hope this helps!
In my "C" files, I use a comment format and #define line like this:
/** #brief Number of milli-seconds to wait*/
#define kTimeoutMSec (2)
My html documents do end up containing documentation I specify. (I do have #file at the top of the file and EXTRACT_ALL=YES)
Try setting EXTRACT_ALL option, I have that set in my project and it generates documentation for #defines. There might be a more elegant way of doing it without using EXTRACT_ALL so be sure to check the documentation
http://www.doxygen.nl/config.html#cfg_extract_all
Adding to the previous answers, it is also needed to have ENABLE_PREPROCESSING=YES on the Doxyfile.

Documenting namespaces with Doxygen

I'm having issues with Doxygen recognizing namespaces and modules. I believe the issue surrounds whether to place the \addtogroup within the namespace or outside the namespace.
Example 1, outside the namespace:
/*!
* \addtogroup Records
* #{
*/
//! Generic record interfaces and implementations
namespace Records
{
//! Describes the record interface
class Interface;
} // End namespace Records
/*! #} End of Doxygen Groups*/
Example 2 - within namespace
//! Generic record interfaces and implementations
namespace Records
{
/*!
* \addtogroup Records
* #{
*/
//! Describes the record interface
class Interface;
/*! #} End of Doxygen Groups*/
} // End namespace Records
I would like the namespace Records to appear under the Doxygen Namespaces tab and indirectly under the Modules tab. Clicking on the item in the Namespaces page should produce a page containing Records::Interface. Clicking on the item in the Modules tab should also produce a page containing Records::Interface.
In my Doxygen documentation, I have items missing from Namespaces tab that are in Modules and vice-versa, due to my inconsistency resulting from this dilemma.
So which is the proper method, Example 1 or Example 2?
{The Doxygen manual is not clear on this topic.}
Doxygen: \addtogroup
Doxygen: documenting namespaces
I have performed an experiment using Doxygen and the two examples and here are the results.
The class names in the examples have been renamed to avoid confusion with Doxygen.
Example 1, Outside Namespace
/*!
* \addtogroup Records
* #{
*/
//! Generic record interfaces and implementations
namespace Records
{
//! Describes the record interface
class Interface;
} // End namespace Records
/*! #} End of Doxygen Groups*/
Doxygen Results:
Click on Modules button (in the main bar).
Click on "Records" module in the window.
Example 2: Within Namespace (class renamed to Fields)
//! Generic record interfaces and implementations
namespace Fields
{
/*!
* \addtogroup Fields
* #{
*/
//! Describes the record interface
class Interface;
/*! #} End of Doxygen Groups*/
} // End namespace Fields
Doxygen Results:
Click on Modules button (in the main bar).
Click on "Records" module in the window.
Summary
The location of Doxygen \addtogroup command has different results depending on whether it is located within a namespace definition or outside. When declared outside of a namespace, the Doxygen Modules tab will show the namespace, as shown in Example 1 above. When the \addtogroup command is placed inside a namespace, the Doxygen Modules tab will not display the namespaces as shown in Example 2 above. If you want your namespace to be listed in the Doxygen Modules tab, locate the \addtogroup command outside of the namespace.
As an alternative, you could also use \ingroupRecords in the namespace documentation:
/**
* \defgroup Records Title for records module
* #brief Short doc of Records
*
* Long doc of Records.
*/
/**
* #brief Generic record interfaces and implementations
*
* \ingroup Records
*/
namespace Records {
/// Describes the record interface
class Interface;
} /* namespace Records */