Javadoc

From Seo Wiki - Search Engine Optimization and Programming Languages
Jump to navigationJump to search

Javadoc is a documentation generator from Sun Microsystems for generating API documentation in HTML format from Java source code.

The "doc comments" format used by Javadoc is the de facto industry standard for documenting Java classes. Some IDEs [1], such as Netbeans and Eclipse automatically generate Javadoc HTML. Many file editors assist the user in producing Javadoc source and use the Javadoc info as internal references for the programmer.

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.

Structure of a Javadoc comment

A Javadoc comment is set off from code by standard multi-line comment tags /* and */. The opening tag, however, has an extra asterisk, as in /**.

  1. The first paragraph is a description of the method documented.
  2. Following the description are a varying number of descriptive tags, signifying:
    1. The parameters of the method (@param)
    2. What the method returns (@return)
    3. Any exceptions the method may throw (@throws)
    4. Other less-common tags such as @see (a "see also" tag)

Overview of Javadoc tags

Some of the available Javadoc tags[2] are listed in the table below:

Tag & Parameter Usage Applies to Since
@author name Describes an author. Class, Interface
@version version Provides version entry. Max one per Class or Interface. Class, Interface
@since since-text Describes since when this functionality exists. Class, Interface, Field, Method
@see reference Provides a link to other element of documentation. Class, Interface, Field, Method
@param name description Describes a method parameter. Method
@return description Describes the return value. Method
@exception classname description
@throws classname description
Describes an exception that may be thrown from this method. Method
@deprecated description Describes an outdated method. Method
{@inheritDoc} Copies the description from the overridden method. Overridding Method 1.4.0
{@link reference} Link to other symbol. Class, Interface, Field, Method
{@value} Return the value of a static field. Static Field 1.4.0

Example

An example of using Javadoc to document a method follows. Notice that spacing and number of characters in this example are as conventions state.

/**
 * Validates a chess move. Use {@link #doMove(int, int, int, int)} to move a piece.
 * 
 * @param theFromFile file from which a piece is being moved
 * @param theFromRank rank from which a piece is being moved
 * @param theToFile   file to which a piece is being moved
 * @param theToRank   rank to which a piece is being moved
 * @return            true if the move is valid, otherwise false
 */
boolean isValidMove(int theFromFile, int theFromRank, int theToFile, int theToRank)
{
    ... 
}
 
/**
 * Moves a chess piece.
 *
 * @see java.math.RoundingMode
 */
boolean doMove(int theFromFile, int theFromRank, int theToFile, int theToRank)
{
    ... 
}

Criticism

The pages generated by Sun's Javadoc are static HTML pages that use frames instead of more modern, dynamic techniques. Pages do not include a built-in search function.

See also

External links

Notes

cs:Javadoc de:Javadoc es:Javadoc fr:Javadoc it:Javadoc nl:Javadoc ja:Javadoc no:Javadoc nn:Javadoc pl:Javadoc pt:Javadoc ru:Javadoc sv:Javadoc

If you like SEOmastering Site, you can support it by - BTC: bc1qppjcl3c2cyjazy6lepmrv3fh6ke9mxs7zpfky0 , TRC20 and more...