Javadoc linking to a class in another package

无人久伴 提交于 2019-12-18 01:19:11

问题


I have two packages, Shapes and Fruits:

com.myproject.Shapes.
    Circle
    Square
    Triangle
com.myproject.Fruits.
    Apple
    Orange

I am writing the JavaDoc for Apple and need to provide an {@link} to Square.

I have tried all of the following, and none of them work:

{@link Square}
{@link com.myproject.Square}

I've been able to find documentation for linking to: (a) classes within the same package, or (b) externals URLs, but not classes in another package.

Any ideas what the correct syntax should be? Thanks!


回答1:


The correct syntax variants are

{@link [<package>.]<class>[#<method>]}
{@link #<method>}

You were missing a complete package. The following example should be correct

{@link com.myproject.Shapes.Square} 
                     ^^^^^^



回答2:


For another package use this syntax:

{@link  package.class#member  label}

In your case this should be:

{@link com.myproject.Shapes.Square Square}

If you want to show only the class name then use the label, if complete path is desired then label is not required.

Reference: http://docs.oracle.com/javase/7/docs/technotes/tools/windows/javadoc.html#link



来源:https://stackoverflow.com/questions/7287374/javadoc-linking-to-a-class-in-another-package

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!