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

后端 未结 2 1314
盖世英雄少女心
盖世英雄少女心 2021-01-06 08:41

For example, in my function

//starting code with doxygen documentation
/** The main function. I will now try to document variables within this main function*         


        
相关标签:
2条回答
  • 2021-01-06 08:56

    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.

    0 讨论(0)
  • 2021-01-06 08:57

    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.

    0 讨论(0)
提交回复
热议问题