Using Javadoc 1.5, I have been unable to create a @link to an Enumeration value.
使用Javadoc 1.5,我无法创建到枚举值的@链接。
What I would like to do is to create an Enum like this:
我想做的是创建这样一个Enum:
public enum Planet {
/**
* MERCURY is a fun place.
*/
MERCURY,
/**
* VENUS is more fun.
*/
VENUS,
/**
* But nothing beats the Earth.
*/
EARTH,
/**
* Others we know nothing about.
*/
OTHERS
}
And then refer to the Javadoc for Earth using a link like this:
然后使用如下链接参考Javadoc的地球:
{@link Planet.EARTH}
I have tried the {@link Planet#EARTH}
style too, but to no avail.
我也尝试了{@link Planet#EARTH}样式,但没有效果。
Anyone know if this is doable at all?
有人知道这是否可行吗?
3 个解决方案
#1
139
The # style works for me:
#风格适合我:
{@link Planet#EARTH}
The key is that the Planet package must be imported, or planet must be fully qualified - i.e.:
关键是行星包装必须进口,或者行星必须完全合格——即:
{@link com.something.somethingelse.Planet#EARTH}
#2
4
I'm using Eclipse to check this, but
我正在使用Eclipse检查这个,但是
{@link Planet#EARTH}
style seems to work. However, I normally prefer
风格似乎工作。但是,我通常喜欢
@see Planet#EARTH
anyway. Not sure what Eclipse uses to generate Javadoc, but I'm using JDK6. Still, maybe @see does the trick for you.
无论如何。不确定Eclipse使用什么来生成Javadoc,但是我使用的是JDK6。不过,@see或许对你有帮助。
#3
2
As long as it's imported you can link it (but when you do this, IMO it makes the imports messy- what ones are used in code and what ones in javadoc? I like to just use the fully qualified name).
只要它是导入的,您就可以链接它(但是当您这样做时,在我看来它会使导入变得混乱——在代码中使用的是什么,在javadoc中使用的是什么?)我喜欢用完全限定名)。
But yes, Eclipse can take care of it all and standard
但是,是的,Eclipse可以处理它的全部和标准
{@link Planet#EARTH}
works fine.
工作很好。
If your using Eclipse, Ctrl + Shift + O (on PC) or Cmd + Shift + O (on Mac) auto-adjust your imports (this means if you have extra imports not being used, they're removed, as well as adding any imports you need).
如果您使用Eclipse, Ctrl + Shift + O(在PC上)或Cmd + Shift + O(在Mac上)自动调整您的导入(这意味着如果您没有使用额外的导入,它们将被删除,并添加您需要的任何导入)。
#1
139
The # style works for me:
#风格适合我:
{@link Planet#EARTH}
The key is that the Planet package must be imported, or planet must be fully qualified - i.e.:
关键是行星包装必须进口,或者行星必须完全合格——即:
{@link com.something.somethingelse.Planet#EARTH}
#2
4
I'm using Eclipse to check this, but
我正在使用Eclipse检查这个,但是
{@link Planet#EARTH}
style seems to work. However, I normally prefer
风格似乎工作。但是,我通常喜欢
@see Planet#EARTH
anyway. Not sure what Eclipse uses to generate Javadoc, but I'm using JDK6. Still, maybe @see does the trick for you.
无论如何。不确定Eclipse使用什么来生成Javadoc,但是我使用的是JDK6。不过,@see或许对你有帮助。
#3
2
As long as it's imported you can link it (but when you do this, IMO it makes the imports messy- what ones are used in code and what ones in javadoc? I like to just use the fully qualified name).
只要它是导入的,您就可以链接它(但是当您这样做时,在我看来它会使导入变得混乱——在代码中使用的是什么,在javadoc中使用的是什么?)我喜欢用完全限定名)。
But yes, Eclipse can take care of it all and standard
但是,是的,Eclipse可以处理它的全部和标准
{@link Planet#EARTH}
works fine.
工作很好。
If your using Eclipse, Ctrl + Shift + O (on PC) or Cmd + Shift + O (on Mac) auto-adjust your imports (this means if you have extra imports not being used, they're removed, as well as adding any imports you need).
如果您使用Eclipse, Ctrl + Shift + O(在PC上)或Cmd + Shift + O(在Mac上)自动调整您的导入(这意味着如果您没有使用额外的导入,它们将被删除,并添加您需要的任何导入)。