Make your own API
How to make your own API.
To make your own API with good documentation, you must comment each public method.
package net.westsoftware.handler;
import java.io.*
/**
* Class to read files
*
* @version 1.00 6 Nov 2006
* @author Firstname Lastname
**/
public class ReadFileHandler{
/** Read an file
* @param <code>String< /code> as in filename
* @return a <code>String</code> of the content
* @throws a <code>IOException</code> if file is not found
*
**/
public String readFile(String file) throws IOException{
String returnContent ="";
//do some reading....
return returnContent;
}
}
You have the files and you have documented your class and methods, so lets build an API.
We'll use the javadoc to create our API. In CMD type:
C:\java\j2sdk1.5\bin\javadoc -author -version -windowtitle "Westsoftware.net Package" -link "C:\java\j2sdk1.5\docs\api" -d "myAPI" *.java
This creates a sub directory "myAPI" with all of the documentation files.
Simply open the index.html.
A tip here is to add this to a .bat file, so you easy can generate a new api whenever you update your code.