开发者

javadoc exclude some public methods from class

开发者 https://www.devze.com 2023-02-07 14:05 出处:网络
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 开发者_JS百科a slight problem :

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 开发者_JS百科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?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消