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.
@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.
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.
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.
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)
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With