Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I write in-code comments and documentation in a proper way? Is there any standard for this? [closed]

I want to add documentation in my code by means of comment lines.
Is there any standard format for this?

For example, consider the code below:

class Arithmetic
{
    // This method adds two numbers, and returns the result.
    // dbNum1 is the first number to add, and dbNum2 is second.
    // The returning value is dbNum1+dbNum2.
    static double AddTwoNumbers(double dbNum1, double dbNum2);
}

For this example code, is there any better way of writing the comment lines?

like image 289
hkBattousai Avatar asked Dec 16 '22 18:12

hkBattousai


2 Answers

For c++ there isn't a standard, like javadoc, but certain documentation tools are popular and common to use. Off the top of my head, I can mention doxygen.

Doxygen also supports the familiar javadoc style, ie:

/**
   This method adds two numbers, and returns the result.
   @param dbNum1 is the first number to add
   @param dbNum2 is second.
   @return The returning value is dbNum1+dbNum2.
*/
static double AddTwoNumbers(double dbNum1, double dbNum2);
like image 138
Mic Avatar answered Dec 19 '22 07:12

Mic


you can format your comments so later you can generate documentation. the most popular tool for this is DoxyGen

like image 40
Andriy Tylychko Avatar answered Dec 19 '22 08:12

Andriy Tylychko