javadoc从类中排除一些公共方法
我必须将类的一些公共方法排除在 javadoc 之外。我尝试了 Chris Nokleberg 的 ExcludeDoclet (sixlegs)。但 doclet 给出了一个小问题: 如果类中的其他方法返回 List (或任何其他泛型), 返回类型不是在 javadoc 中显示为列表,而是仅显示为列表(没有通用信息)
任何人都可以给出提示或提供如何解决此问题的解决方法吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我假设您想要从 javadoc 中排除的方法是您不希望客户端使用的公共方法。换句话说,这些方法已已弃用。您需要做的是使用 @Deprecated 注释。像这样:
现在,badMethod() 已被弃用。如果有人在代码中使用 badMethod(),他会收到编译器的警告(他正在使用已弃用的方法)。
但是,@Deprecated 注释并不从 javadoc 中排除已弃用的方法。为了从 javadoc 中排除该方法,您需要执行以下操作: 生成 javadoc 时,使用 nodeprecated javadoc 命令行选项。 -nodeprecated 选项可防止生成文档中任何已弃用的 API。因此,如果您使用 @Deprecated 注释并使用 -nodeprecated 选项生成 javadoc,那么您的错误方法将不会出现在 javadoc 中。
但在我看来,您不应该从 javadoc 中排除已弃用的公共方法。如果它们出现在文档中,并解释为什么不推荐使用该方法以及使用什么方法,那就更好了。
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:
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.