如何 Javadoc 一个类的个别枚举

我正在为一个包含自己枚举的类编写 Javadoc。有没有为单个枚举生成 Javadoc 的方法?例如,现在我有这样的东西:

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

然而,这只是将所有枚举作为一个整体记录下来:

The generated Javadoc

有没有办法分别记录每个 HairColor值?而不将枚举移动到它自己的类中或者从枚举更改它?

76444 次浏览

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
}