How to write javadoc links?

爷,独闯天下 提交于 2019-12-02 20:01:10

To get a link to something external to your code, you need use the -linkoffline option

where the -linkoffline option has the format something like this (artificially wrapped):

-linkoffline http://java.sun.com/javase/6/docs/api/
             http://java.sun.com/javase/6/docs/api/

This tells the JavaDoc tool where to find the link to the JavaDoc and for what packages to use that link. From the 2nd URL, it will append "package-list" to load the actual URL:

http://java.sun.com/javase/6/docs/api/package-list

which you can verify by loading it in a browser does contain the list of packages documented at that JavaDoc URL. This tells the JavaDoc tool that any @link references to anything in one of those packages should link to the provided URL.

My answer is very much provided by Eddie, but his exact code doesn't work for me (or at least when using the version of javadoc that comes with Java 1.6)

If I do:

    javadoc -linkoffline http://java.sun.com/javase/6/docs/api/ 
                         http://java.sun.com/javase/6/docs/api/package-list
            -public FileName.java

then javadoc complains:

    javadoc: warning - Error fetching URL: 
    http://java.sun.com/javase/6/docs/api/package-list/package-list

If, on the other hand, I do:

    javadoc -linkoffline http://java.sun.com/javase/6/docs/api/ 
                         http://java.sun.com/javase/6/docs/api/ 
            -public FileName.java

Then it works, and my links are populated as I want them to be.

Additionally, my link isn't malformed. The text {@link java.lang.Math#sqrt(double) Math.sqrt} produces the link text Math.sqrt instead of the default Math.sqrt(double).

Sebastian Oliva

This document might be of assistance, remember that for @link you need to use the URL for the doc you are linking to.

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