简体   繁体   English

如何从Javadoc中排除已弃用的公共方法?

[英]How to exclude deprecated public methods from Javadoc?

I would like to generate javadoc for my classes. 我想为我的类生成javadoc。 The 'generate Javadoc' command gives me an option to create Javadoc for members with visibility Private/Package/Protected/Public. 'generate Javadoc'命令为我提供了为具有可见性Private / Package / Protected / Public的成员创建Javadoc的选项。 But there are some public methods I don't want to be included in the Javadoc. 但是有些公共方法我不想被包含在Javadoc中。 How can I specify for this Javadoc generator exactly which members/methods to include and which ones to not include? 如何为此Javadoc生成器指定要包含哪些成员/方法以及哪些成员/方法不包含?

(I use eclipse 3.4.2) (我使用eclipse 3.4.2)

Edit: Some of you asked what is the reason I want to do this. 编辑:有些人问我想要这样做的原因是什么。 The reason is that I have some methods which I don't want to exist but I still need them to work for backward compatibility. 原因是我有一些我不想存在的方法,但我仍然需要它们来实现向后兼容。 I marked them as @deprecated so that people who try to use them will recieve a warning. 我将它们标记为@deprecated,以便尝试使用它们的人会收到警告。 But I don't want them to appear at all in the Javadoc. 但我不希望它们出现在Javadoc中。 Is there a way to exclude them from the javadoc given they're marked @deprecated? 有没有办法将它们从javadoc中排除,因为它们被标记为@deprecated?

那么,为什么javadoc -nodeprecated不能解决问题呢?

你必须编写自己的Doclet

So you have some methods that must be public for some reason, but are something that class users should not really mess with? 所以你有一些必须公开的方法由于某种原因,但是类用户不应该真的搞乱吗?

You could put this kind of JavaDoc for those "hidden" public methods: 您可以将这种JavaDoc用于那些“隐藏”的公共方法:

 /**
  * !!! THIS METHOD IS NOT PART OF PUBLIC INTERFACE !!!
  * !!! DO NOT USE !!!
  */
 public void somethingThatShouldNotBeUsedByOutsiders()

I took a quick glance and there seems to be no way to do method level exclusions at least via the standard JavaDoc tools . 我快速浏览了一下,至少通过标准的JavaDoc工具似乎无法进行方法级排除。

As Software Monkey wrote, you probably have to write your own Doclet. 正如Software Monkey所写,你可能需要编写自己的Doclet。 There's an example which does nearly what you wanted, the ExcludeDoclet 有一个例子几乎可以做你想要的, ExcludeDoclet

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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