Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I include @Annotations in JavaDoc? [duplicate]

I would like to document some properties of classes and methods in JavaDoc and be able to load these information at runtime. Therefore I thought it might be convenient to write a custom annotation and annotate all necessary files and methods with this annotation. With this annotation, I could load these information at runtime.

Here's a hypothetic code snippet to demonstrate my use case:

public class ImportantClass {
  @DetailedDescription(description="originated from data source XYZ")
  public void importantMethod() {
    // snip
  }
}

The String "originated from data source XYZ" should be displayed in the JavaDoc and be readable via reflections or something similar. My problem is that the JavaDoc does not contain annotation information.

Is it possible to configure the JavaDoc task (preferrably with Maven) to include annotation information?

Clarification: I'm not interested in doclets (~javadoc annotations) as they are not readable at runtime.

like image 920
guerda Avatar asked Dec 03 '13 15:12

guerda


1 Answers

I finally found a nice solution without duplication. Use the @Documented annotation on the annotation interface (DetailedDescription in this case) and all instances of this annotation are documented in the JavaDoc. See this question:

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

like image 146
guerda Avatar answered Oct 24 '22 13:10

guerda