简体   繁体   中英

How to create JavaDoc which contains only classes/method annotated with custom Annotation?

Situation is like: The client wants to have a documentation for public API. We do have particular methods documented and annotated with @PublicAPI custom annotation ( to prevent these function from obfuscation ).

Now we would like to generate JavaDocs only for these methods. We are using gradle, and I know that I can filter sources, but it is not sufficient for us - API changes frequently.

Any ideas?

You should use a custom Doclet like this one . Just adapt the exclude method. An then, create a custom Javadoc task :

task generatePublicAPIDocs(type: Javadoc) {
  source = sourceSets.main.allJava
  destinationDir = your/dest/dir
  options.docletpath = your/doclet/path
  options.doclet = "com.yourdoclet.TheDoclet"
}

I've been using the ExcludeDocklet for years and it works great. Just use a @exclude javadoc tag on any class, member, field or package and it will be excluded from the generated javadoc.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM