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

删除回忆录丶 提交于 2019-12-01 21:24:58

I do not know a way to do that (and I do doubt that there exists a way). Remember, that doxygen was made to document classes and function headers, i.e. 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. However, as you are programming in C(++), it should not be a problem to document local variables in source. Just give it a proper name or document it "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 demanded by you would make sense though.

While you can put comments in the body of a function and let them appear as part of the function documentation like so

/** @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 already pointed out. If you want (as a developer) to read the sources along with the documentation, you can better use normal 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 setting INLINE_SOURCES to YES.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!