Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to write javadoc links?

How do I write links into javadocs?

Currently, I have something like:

{@link java.lang.Math#sqrt(double) Math.sqrt} 

to produce the text Math.sqrt that should link to the java.lang.Math.sqrt(double) API, however, all it does is produce the text, no link.

like image 755
masher Avatar asked Mar 31 '09 02:03

masher


People also ask

How do you add a link to a Javadoc?

@see <a href="URL#value">label</a> : Adds a link as defined by URL#value . The URL#value is a relative or absolute URL. The Javadoc tool distinguishes this from other cases by looking for a less-than symbol ( < ) as the first character.

What is Javadoc give example?

Javadoc is a tool which comes with JDK and it is used for generating Java code documentation in HTML format from Java source code, which requires documentation in a predefined format. Following is a simple example where the lines inside /*…. */ are Java multi-line comments.

What should be included in a Javadoc?

Before using JavaDoc tool, you must include JavaDoc comments /**……………….. */ providing information about classes, methods, and constructors, etc. For creating a good and understandable document API for any java file you must write better comments for every class, method, constructor.


1 Answers

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

like image 82
masher Avatar answered Sep 24 '22 04:09

masher