To create java documentation, we need to write documentation command while writting code itself.
Documentation command look like this,
/**
*
* Description of Packagae / Class / Method / Variables
*/
If we wrote like this, then we can easily generate Java Api for our Application.
Example:
package javaexamples;
/**
*
* @author uma
*/
/**
*
* This class implements usage of toString in java.
* If we override this toString(), then when ever we print this class's object,
* It will display all information about that object
* what ever we defined in this toString() method
*/
public class Student {
/**
* id is an unique key to identify Student
*/
private int id;
/**
* name of the Student
*/
private String name;
/**
* Student constructor initialize id and name of the Student
*/
public Student(int id, String name) {
this.id = id;
this.name = name;
}
/**
* The toString() will display Student class 's object information
*/
public String toString() {
return "Id :" + id + " Name :" + name;
}
}
To create Javadoc, need to run this commmand or use 'Generate javadoc' option in netbeans.
javadoc [ option ] package_name
[ To know about all options, use javadoc command. It will list all options ]
From above example,
javadoc -private javaexamples
This will give complete javadoc in html file. Once, we open this index.html in browser, It will show all details.
No comments:
Post a Comment