Raydel Miranda
Raydel Miranda

Reputation: 14360

Javadoc: Just one comment for multiple global variable declarations

I´m documenting a source code I wrote in C++ using Doxygen. I have a file that contains just constants definitions, for instance:

// Flags for A
const int A = 0;
const int A1 = 1;
const int A2 = 2;
// Flags for B
const int B = 0;
const int B1 = 1;
const int B2 = 2;

What I want is javadoc syntax to generate documentation for A flags and for B flags separately. I dont want to separate them in different files and neither write a doc comment for each one of the constants.

Is that possible? If it is, how?

Upvotes: 3

Views: 917

Answers (1)

Thomas Matthews
Thomas Matthews

Reputation: 57739

You could enclose them inside a Doxygen group:

/*!
 * \addtogroup A_Flags
 * @{
 */
 const int A = 0; //!< Bit zero;
 const int A1 = 1; //!< Bit position 1;
 const int A2 = 2; //!< Bit position 2;
/*! @} End of group A_Flags */


/*!
 * \addtogroup B_Flags
 * @{
 */
 const int B = 0; //!< Bit zero;
 const int B1 = 1; //!< Bit position 1;
 const int B2 = 2; //!< Bit position 2;
/*! @} End of group B_Flags */

I did something similar to this with our FPGA registers, detailing the bit values.

/*!
 *  @addtogroup FPGA_CLEAR_WATCHDOG_FAULT_MAP
 *  @{
 *  \image html FPGA_Clear_Watchdog_Fault_Register.JPG "Clear Watchdog Fault Register"
 */

/*! Clear Watchdog Fault flag.\n
 *  <code>
 *  binary: 0000 0000 0000 0001\n
 *  hex:      0    0    0    1\n
 *  </code>
 */
#define FPGA_CLEAR_WATCHDOG_FAULT           (0x0001U)

/*! Inform FPGA of shutdown
 *  <code>
 *  binary: 0000 0000 0000 0010\n
 *  hex:      0    0    0    2\n
 *  </code>
 */
#define FPGA_INFORM_SHUTDOWN                (0x0002U)

/*! @} End of Doxygen group FPGA_CLEAR_WATCHDOG_FAULT_MAP*/

Upvotes: 4

Related Questions