Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add reference to a method parameter in javadoc?

Is there a way to add references to one or more of a method's parameters from the method documentation body? Something like:

/**  * When {@paramref a} is null, we rely on b for the discombobulation.  *  * @param a this is one of the parameters  * @param b another param  */ void foo(String a, int b) {...} 
like image 527
ripper234 Avatar asked Nov 03 '09 13:11

ripper234


People also ask

How do you reference a method in Javadoc?

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.

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.


2 Answers

As far as I can tell after reading the docs for javadoc there is no such feature.

Don't use <code>foo</code> as recommended in other answers; you can use {@code foo}. This is especially good to know when you refer to a generic type such as {@code Iterator<String>} -- sure looks nicer than <code>Iterator&lt;String&gt;</code>, doesn't it!

like image 177
Kevin Bourrillion Avatar answered Sep 25 '22 00:09

Kevin Bourrillion


The correct way of referring to a method parameter is like this:

enter image description here

like image 29
Eurig Jones Avatar answered Sep 23 '22 00:09

Eurig Jones