How can I get javadoc of all methods with specific annotation, with method name and package / class name?

I am looking for a way to get all javadoc for all methods with specific annotation at runtime. I am going to use this javadoc to display the details of these methods in the user interface.

These methods are later used for testing, they will be called in an unknown order, defined by the user - I want the user to be able to see javadoc without having to browse the sources.

Yes, I have sources and you can use them to achieve the goal.

The best way I thought about this is to maintain a separate description file that will be read at runtime, but that means I have to support both javadoc and an external file, and I don't like the idea of ​​keeping two copies of pretty similar text .

Cheers for any answers! Thank.

+5
source share
3 answers

It is not as simple as it seems, because JavaDoc is not part of the class file (there is java.lang.reflect.Methodno method getJavaDoc()).

I would attack the problem as follows:

  • Download JDT Eclipse. It contains the Java Eclipse compiler (add org.eclipse.jdt.core_*.jarto your classpath. Using the batch compiler "may also help).
  • . AST Java Eclipse.
  • AST : , , . JavaDoc, AstVisitor
  • , , XML- ( ), .
  • Ant, .
+2

, , javadocs . Solr, Lucene, Sphinx - , .

, , JavaDocs . , Lucene http://www.lucenetutorial.com/lucene-in-5-minutes.html

0

It is possible, but requires some effort.

Typically, javadoc creation is achieved by running a utility javadocthat reaches the CLI. You can call it at compile time using the annotation processor API and save along with your compiled resources. Then you can read it at runtime.

Please see this project as a great example of using the annotation preprocessor.

0
source

All Articles