开发者

How to Javadoc a Class's Individual Enums

I am writing the Javadoc for a class that contains its own enums. Is there a way to generate Javadoc for the individual enums? For example, right now I have something like this:

/**
 * This documents "HairColor"
 */
private static enum HairColor { BLACK, BLONDE, BROWN, OTHER, RED };

However, this only documents all of the enums as a whole:

How to Javadoc a Class's Individual Enums

Is there any way to document each of the HairColor values individuall开发者_如何学Goy? Without moving the enum into its own class or changing it from an enum?


You do it just like any other variable you would javadoc.


/**
 *  Colors that can be used
 */
public enum Color
{
    /**
     * Red color
     */
    red,

    /**
     * Blue color
     */
    blue

}

EDIT:

From Paŭlo Ebermann : The enum is a separate class. You can't include its full documentation in the enclosing class (at least, without patching the standard doclet).


You can create link to each enum's item. All items will be listed in javadocs to enum class.

/**
 *  Colors that can be used
 *  {@link #RED}
 *  {@link #BLUE}
 */
public enum Color {

    /**
     * Red color
     */
     RED,

    /**
     * Blue color
     */
    BLUE
}


With @see anotation

 /**
 *  Colors that can be used
 *  @see #RED
 *  @see #BLUE
 */
public enum Color {

    /**
     * Red color
     */
     RED,

    /**
     * Blue color
     */
    BLUE
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜