Code:
#include <stdio.h>
/*
* \var int iOne
* \brief Integer 1
*/
/*
* \var int iTwo
* \brief Integer 2
*/
/*
* \var int iThree
* \brief Integer 3
*/
/**
* \brief Imitates a sheep.
*/
void sheep();
/**
* \brief Main function for test code
*/
int main() {
int iOne, iTwo, iThree;
iOne = 1;
iTwo = 2;
iThree = 3;
printf("%d %d %d", iOne, iTwo, iThree);
return 0;
}
void sheep() {
printf("Meeeh");
}
This doesn't generate descriptions for iOne
, iTwo
and iThree
although that was my intention. How do I fix this?
To use Doxygen, you simply comment your source code in a syntax that Doxygen can read. Doxygen then walks through your source files and creates HTML or LaTeX documentation based on those special comments.
From the Doxygen www site: "Doxygen is the de facto standard tool for generating documentation from annotated C++ sources, but it also supports other popular programming languages such as C, Objective-C, C#, PHP, Java, Python, IDL (Corba and Microsoft flavors), Fortran, VHDL, Tcl, and to some extent D."
Putting the command @brief will generate a short description of the function when you generate the doxygen documentation. That short description can be extended if you want.
The section "Special Commands" lists the \def command, and the section "Automatic link generation" describes what you want to link to the macro. Use \def to document a macro separate from the declaration. Use #MACRO(params) to auto-link to said macro definition.
DOxygen was made to document classes and function headers or, in other words, the interface. Think of the documentation as something that other programmers study in order to use your classes and functions properly. You shouldn't use DOxygen to document your implementation. Instead, document your local variables in the source with //
or /* */
.
There are a number of ways to make comments in DOxygen, some examples of which (for member variables) can be seen in the manual here. I've copied them below.
int var; /*!< Detailed description after the member */
int var; /**< Detailed description after the member */
int var; //!< Detailed description after the member
//!<
int var; ///< Detailed description after the member
///<
int var; //!< Brief description after the member
int var; ///< Brief description after the member
You need to open your comments as Doxygen comments with /**
.
It may be clearer to do this, though:
int main() {
/** \brief Integer 1 */
int iOne;
/** \brief Integer 2 */
int iTwo;
/** \brief Integer 3 */
int iThree;
/** ... and so on ... */
}
This way you can change the name of the variable without breaking your documentation and it's also easier on other programmers who need to read your source code because the description of the variable is located next to it, not somewhere else in the file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With