Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Writing proper javadoc with @see?

Tags:

java

javadoc

How do I use the @see javadoc properly?

My intention is to have an abstract class with abstract methods. These methods have javadoc comments. Now if I extend the abstract class, I override the methods and want to use @see.

But for all params, eg for return the @see link does not seem to work. Eclipse still complains that expected @return tag.

So how can I use this?

public abstract class MyBase {
  protected abstract void myFunc();
}

class MyImpl extends MyBase {

  /**
   * @see MyBase#myFunc()
   */
  @Override
  protected void myFunc() { .. }
}
like image 249
membersound Avatar asked Jun 20 '12 14:06

membersound


People also ask

How do you write a Javadoc style comment?

Writing Javadoc Comments In general, Javadoc comments are any multi-line comments (" /** ... */ ") that are placed before class, field, or method declarations. They must begin with a slash and two stars, and they can include special tags to describe characteristics like method parameters or return values.

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.


1 Answers

For the purpose of including the documentation from a superclass you should use {@inheritDoc} not @see.

Then you get the docs of the superclass. You can add to it, and you can override stuff like @param and @return if you need to.

public abstract class MyBase {
  /**
   * @param id The id that will be used for...
   * @param good ignored by most implementations
   * @return The string for id
   */
  protected abstract String myFunc(Long id, boolean good);
}

class MyImpl extends MyBase {

  /**
   * {@inheritDoc}
   * @param good is used differently by this implementation
   */
  @Override
  protected String myFunc(Long id, boolean good) { .. }
}
like image 62
Superole Avatar answered Oct 12 '22 23:10

Superole