Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaDoc giving fully-qualified class name... how to abbreviate?

Problem

I'm running mvn javadoc:javadoc to generate JavaDoc, and I am pleased with the results, except for one thing: it gives the fully qualified class names for any class coming from a third-party library or our own codebase. For example,

It gives a return type of com.project.beans.BeanA, com.project.beans.BeanB for methods that return one of these classes.

It gives a param type of org.codehaus.jettison.json.JSONObject for a method that takes a JSON object. (Whereas it gives a param type of Integer for a method that takes a java.lang.Integer.)

Question

Is there any way to generate the shorthand names for these classes, for readability purposes? i.e. BeanA, BeanB, JSONObject.

And is there a way to do this without any XML configuration?

Thanks in advance :-)

like image 688
ktm5124 Avatar asked Jan 12 '13 23:01

ktm5124


People also ask

How do you cite a class 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 write a good Javadoc?

The correct approach is an @param tag with the parameter name of <T> where T is the type parameter name. There should be one blank line between the Javadoc text and the first @param or @return. This aids readability in source code. The @param and @return should be treated as phrases rather than complete sentences.

What are Javadoc tags?

The javadoc TagsRepresents the relative path to the generated document's root directory from any generated page. Adds a comment indicating that this API should no longer be used. Adds a Throws subheading to the generated documentation, with the classname and description text.

How do I read a Javadoc?

Accessing the Javadoc from NetbeansSelect the desired package, class or method name, right-click and select Show Javadoc. This will launch your default web browser and navigate to the Javadoc for the selected item.


1 Answers

I believe that what you want is the -noqualifier javadoc option which can be set directly from the maven javadoc:javadoc command.

Usually to pass the parameter to a maven plugin you just do like for other Java programs using -D, in this case it would be mvn -Dnoqualifier=all javadoc:javadoc but as far as I can tell the noqualifier does not seems to ben set as an expression in the plugin source so I don't really know if you can pass it via the command line.

If it does not work, you can either modify your pom.xml and add the <noqualifier>all</noqualifier> to the config of the javadoc plugin. Or you could create a property in your pom that will be given as a value for the <noqualifier> tag, but this time the property can be overridden using the command line.

like image 164
Alex Avatar answered Oct 21 '22 08:10

Alex