How to Javadoc a Class's Individual Enums

2020-06-06 07:33发布

I am writing the javadoc for a class that contains it's 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:

The generated Javadoc

Is there any way to document each of the HairColor values individually? Without moving the enum into it's own class or changing it from an enum?

Thanks in advance for any help.

2条回答
家丑人穷心不美
2楼-- · 2020-06-06 08:29

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).

查看更多
爷的心禁止访问
3楼-- · 2020-06-06 08:36

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

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

    /**
     * Red color
     */
     RED,

    /**
     * Blue color
     */
    BLUE
}
查看更多
登录 后发表回答