Wednesday, 29 June 2016

java - How to reference a method in javadoc?




How can I use the @link tag to link to a method?



I want to change



/**
* Returns the Baz object owned by the Bar object owned by Foo owned by this.
* A convenience method, equivalent to getFoo().getBar().getBaz()
* @return baz
*/
public Baz fooBarBaz()



to



/**
* Returns the Baz object owned by the Bar object owned by Foo owned by this.
* A convenience method, equivalent to {@link getFoo()}.{@link getBar()}.{@link getBaz()}
* @return baz
*/
public Baz fooBarBaz()



but I don't know how to format the @link tag correctly.


Answer



You will find much information about JavaDoc at the Documentation Comment Specification for the Standard Doclet, including the information on the




{@link package.class#member label}





tag (that you are looking for). The corresponding example from the documentation is as follows




For example, here is a comment that refers to the getComponentAt(int, int) method:



Use the {@link #getComponentAt(int, int) getComponentAt} method.




The package.class part can be ommited if the referred method is in the current class.







Other useful links about JavaDoc are:




No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...