How to use Doxygen to document local variables in C ++ functions

For example, in my function

//starting code with doxygen documentation
/** The main function. I will now try to document variables within this main function*/
int main()
{
 int arr[]; /** \brief an integer array*/
 .....
 return 0;
}
//end of code

      

However, when I use Doxygen with the "HIDE_IN_BODY_DOCS" variable set in the "NO" config file, it does not execute the specific documentation for that local variable. Rather, it just takes that bit and prints it along with the function documentation, as if it were any other comment line inside the function

How can I document local variables like this using Doxygen?

+3


source to share


2 answers


I don't know how to do this (and I doubt there is a way). Remember doxygen was made to document the classes and headers of the functions, i.e. the interface. Think of documentation as something other programmers learn to use your classes and functions correctly. You shouldn't use doxygen to document your implementation. However, since you are programming in C (++), it shouldn't be a problem to document local variables in source. Just give it your own name or write it down "in source":

Cat cats[]; // holds a bunch of cats



In languages ​​where you define all your variables must be declared at the beginning of your function (Delphi, Pascal), the system you require makes sense.

+4


source


For now, you can put comments in the body of the function and let them appear as part of the function documentation, for example

/** @file */

/** The main function. I will now try to document 
 *  variables within this main function.
 */
int main()
{
  /** an integer array. */
  int arr[];

  /** An endless loop */
  for (;;) {}

  return 0;
}

      

This is generally not recommended as others have already pointed out. If you want (as a developer) to read the sources along with the documentation, you might be better off using regular C comments in the body



/** @file */

/** The main function. I will now try to document 
 *  variables within this main function.
 */
int main()
{
  /* an integer array. */
  int arr[];

  /* An endless loop */
  for (;;) {}

  return 0;
}

      

along with the setting INLINE_SOURCES

- YES

.

+1


source







All Articles