Javadoc
From Wikipedia, the free encyclopedia
Javadoc is a computer software tool from Sun Microsystems for generating API documentation into HTML format from Java source code.
Javadoc is the industry standard for documenting Java classes. Most IDEs will automatically generate Javadoc HTML.
Javadoc also provides an API for creating doclets and taglets, which allows you to analyze the structure of a Java application. This is how JDiff can generate reports of what changed between two versions of an API.
Contents |
To document all the classes in a folder, run the following from the command line (or place it in a batch file and run that). Depending on your installation directory, you may have to tweak this example, but it will create a directory with documentation of all your classes:
"C:\Program Files\Java\jdk1.6.0\bin\javadoc" -d doc *.java
By default, only public members are shown. For deeper visibility, use any of the following switches:
- -protected
- -package
- -private
Developers use certain commenting styles and Javadoc tags when documenting source code. A Java block comment starting with /** will begin a Javadoc comment block which will be included in the generated HTML. A Javadoc tag begins with an "@" (at sign). Some tags are provided in the following table.
-
Tag Description @author Developer name @deprecated Marks a method as deprecated. Some IDEs will issue a compilation warning if the method is called. @exception Documents an exception thrown by a method — also see @throws. @param Defines a method parameter. Required for each parameter. @return Documents the return value. This tag should not be used for constructors or methods defined with a void return type. @see Documents an association to another method or class. @since Documents when a method was added to a class. @throws Documents an exception thrown by a method. A synonym for @exception introduced in Javadoc 1.2. @version Provides the version number of a class or method.
An example of using Javadoc to document a method follows. Notice that spacing and quantity of characters in this example are as conventions state.
/**
* Validates a chess move.
*
* @param theFromFile File of piece being moved
* @param theFromRank Rank of piece being moved
* @return true if a valid chess move or false if invalid
* @author John Doe
*/
boolean isValidMove(int theFromFile, int theFromRank, int theToFile, int theToRank)
{
...
}
- Javadoc tool web site
- How to Write Doc Comments for the Javadoc Tool
- JSR 260 Javadoc Tag Technology Update Java Specification Request (defines new Javadoc tags)
- Improve on Javadocs with ashkelon
- A collection of Javadoc doclets
- An index to many Javadoc generated websites
- JavadocOnline: Search engine project, to get public Javadocs over Internet
- DocJar: Another search engine project, to get public Javadocs over Internet
- Globaldocs: A viewer to browse multiple Javadocs simultaneously.
- Various Java documentations converted to Windows Help format