// inline comment, no javadoc generated
Existuje mnoho druhů dokumentací dle účelu:
Při psaní dokumentace dodržujeme tato pravidla:
public a protected metody.
řádkové - od značky // do konce řádku, nepromítnou se do dokumentace
// inline comment, no javadoc generated
blokové - mohou být na libovolném počtu řádků, nepromítnou se do dokumentace
/* block comment, no javadoc generated */
dokumentační - libovolný počet řádků, promítnou se do dokumentace
/** documentary comment, javadoc generated */
javadoc@author, v dokumentačních komentáříchjavadocJavadoc používá značky vkládané do dokumentačních komentářů; hlavními jsou:
@authorspecifikuje autora
@parampopisuje jeden parametr metody
@returnpopisuje co metoda vrací
@throwspopisuje informace o výjimce, kterou metoda propouští ("vyhazuje")
a další…
public a protected metodypackage-info.html v příslušném balíku/**
* This class represents a point in two dimensional space.
*
* @author Petr Novotny
**/
public class Vertex2D { ... }
/**
* Returns a string representation of the object. In general, the
* {@code toString} method returns a string that
* "textually represents" this object. The result should ...
*
* @return a string representation of the object.
*/
public String toString() { ... }
{@code toString} značí formátování, vypíše to toString neproporcionálním písmem./**
* Returns the smaller of two int values.
* If the arguments have the same value, the result is that same value.
*
* @param a an argument.
* @param b another argument.
* @return the smaller of {@code a} and {@code b}.
*/
public int min(int a, int b) {
return (a <= b) ? a : b;
}
Dokumentační komentáře uvádíme:
Komentáře lžou — změním kód a zapomenu upravit komentář
/**
* Calculates velocity.
*/
System.out.println(triangle.getArea());
Zbytečné komentáře
private int size; // creates size
/