According to the link, i wrote the following code:
/** * @hide * */ public void myMethod() { // do something }
When i use the command to generate the doc:
$ javadoc -locale en_US -encoding UTF-8 -charset UTF-8 -d doc xxx.java
The doc still have the myMethod
item. So how to hide the myMethod
? What did i miss ?
Advertisement
Answer
You are using a Doclava tag, but are generating the API documentation using the standard doclet.
Building Doclava
The Doclava source comes bundled with an ant script to build the doclet. The “jar” task will build a jar containing Doclava and all necessary dependencies.
Using Doclava with Javadoc
The command line arguments to pass to Javadoc to use Doclava are:
-doclet com.google.doclava.Doclava -docletpath ${jar.file}
As per the official Javadoc FAQ, hiding public members is currently not possible in a direct way.
Occasionally you might need to make a class or method public so that it can be accessible from other packages, not because you want it to be part of the public API. Having these methods appear in the documentation merely confuses application developers.
There is currently no Javadoc option to hide, exclude or suppress public members from the javadoc-generated documentation.
Several options are available:
- Excluding source files – You can pass into javadoc only the source filenames for all classes you want to document, and exclude those you want to omit. Notice this has the granularity of files, not classes. Therefore, if you exclude a source file that contains nested classes, they would also be excluded. (You can put the list of classes in a command line argument file rather than directly on the command line.) The default Javadoc offers no way to omit classes when passing in package names on the command line.
- Excluding individual classes – You can use the Exclude Doclet. This has finer granularity (class rather than source file) than the previous option, and would be more natural to use because you explicitly list in a file the files you want to exclude.
- Excluding classes, methods and fields – The yDoc Doclet has this capability, where you mark items with an exclusion tag in the source code. In addition, anyone is welcome to extend the Exclude Doclet above for methods and fields — we’d be happy to publish it and add your name to the credits.
We are considering @exclude as a proposed tag for excluding members.
Also check out the Proposed Javadoc Tags page for more info into @exclude
and @hide
.