Is there correct JavaDoc syntax for {@link Foo.class}
? Neither this, nor {@link Foo#class}
works. Or is this not possible?
Let me expand a bit:
I have a function registerException(Class<? extends Exception> exceptionClass)
that get's called with things like registerException(IOException.class)
and started writing the following JavaDoc for it:
/**
* Registers a new {@link Class Class<? extends Exception>}
* (e.g. <code>IOException.class</code>} that can be flattened by this handler.
*
* @param exceptionClass - the exception class
*/
and I was thinking whether I could place a {@link ...}
around IOException.class
.
Javadoc provides the @link inline tag for referencing the members in the Java classes. We can think of the @link tag as similar to the anchor tag in HTML, which is used to link one page to another via hyperlinks. Similar to the anchor tag, the path_to_member is the destination, and the label is the display text.
In short, we use the @see tag when we want a link or a text entry that points to a reference. This tag adds a “See Also” heading to the reference. A document comment can hold any number of @see tags, all of which can be grouped under the same heading.
It's a best practice to include a constructor in a class. However, if the constructor is omitted, Javadoc automatically creates a constructor in the Javadoc but omits any description of the constructor.
All public methods must have a doc comment except: Methods that implement or override a method in an interface or superclass without adding any interesting behaviour beyond what is already documented for the overridden method.
The .class is not needed (and apparently doesn't work).
As noted in a comment, {@link IOException IOException.class} should create a link with an appropriate text label.
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