javadoc exclude some public methods from class

落花浮王杯 提交于 2019-12-12 16:25:10

问题


I have to exclude a few of the public methods of a class from being included in javadocs. I tried Chris Nokleberg's ExcludeDoclet (sixlegs). But the doclet is giving a slight problem : If the other methods in the class return List (or any other generics), instead of being displayed in the javadoc as List, return type is just being displayed as List (without the generic info)

Can anyone give a hint or provide a work around on how to solve this issue?


回答1:


I assume the methods you want to exclude from javadoc are public methods that you don't want your client to use. In other words, these methods are deprecated. What you need to do is using the @Deprecated annotation. Like this:

@Deprecated public void badMethod() {
    ...
}

Now, the badMethod() is deprecated. If someone uses badMethod() in his code, he'll get a warning from the compiler (that he's using a deprecated method).

However, the @Deprecated annotation doesn't exclude the deprecated method from javadoc. Here's what you need to do in order to exclude the method from javadoc: When you generate javadoc, use the nodeprecated javadoc cmd line option. The -nodeprecated option prevents the generation of any deprecated API in the documentation. So if you use the @Deprecated annotation and generate javadoc with the -nodeprecated option, your bad method won't appear in the javadoc.

But in my opinion, you shouldn't exclude deprecated public methods from your javadoc. It's better if they appear in the documentation with an explanation of why the method is deprecated and what to use instead.



来源:https://stackoverflow.com/questions/4815502/javadoc-exclude-some-public-methods-from-class

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!