Is there a way to get the javadoc tool to document annotations?

In my project, we use a number of annotations that would be very useful to see in the javadoc API documentation.

Does anyone know a simple way to include annotations in generated javadocs? I don’t want to write my own javadoc plugin. Are there any solutions out there?

Answer

See java.lang.annotation.Documented

Indicates that annotations with a type are to be documented by javadoc and similar tools by default. This type should be used to annotate the declarations of types whose annotations affect the use of annotated elements by their clients. If a type declaration is annotated with Documented, its annotations become part of the public API of the annotated elements.

Example:

import java.lang.annotation.Documented;

@Documented
public @interface MyAnnotation {
}

Leave a Reply

Your email address will not be published. Required fields are marked *