如何 Javadoc 一个类的单个枚举
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6549821/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to Javadoc a Class's Individual Enums
提问by Snowy Coder Girl
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:
我正在为一个包含它自己的枚举的类编写 javadoc。有没有办法为单个枚举生成 javadoc?例如,现在我有这样的事情:
/**
* This documents "HairColor"
*/
private static enum HairColor { BLACK, BLONDE, BROWN, OTHER, RED };
However, this only documents all of the enums as a whole:
但是,这仅将所有枚举记录为一个整体:
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?
有没有办法单独记录每个 HairColor 值?不将枚举移动到它自己的类中或从枚举中更改它?
Thanks in advance for any help.
在此先感谢您的帮助。
采纳答案by user489041
You do it just like any other variable you would javadoc.
您可以像使用 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).
来自 Pa?lo Ebermann :枚举是一个单独的类。您不能在封闭类中包含其完整文档(至少,不修补标准 doclet)。
回答by shushper
You can create link to each enum's item. All items will be listed in javadocs to enum class.
您可以创建指向每个枚举项的链接。所有项目都将列在 javadocs 中以枚举类。
/**
* Colors that can be used
* <li>{@link #RED}</li>
* <li>{@link #BLUE}</li>
*/
public enum Color {
/**
* Red color
*/
RED,
/**
* Blue color
*/
BLUE
}