我可以使用Eclipse轻松地将JavaDoc添加到包中吗?

时间:2023-01-18 23:25:42

I use javadoc to document my classes and methods. I would like to add some overview information to my packages, too. I like how Eclipse creates a stub of a matching Doc Comment for each class or method once I type /**<Enter>. Does Eclipse have an easy way to generate a package.html file, too?

我使用javadoc来记录我的类和方法。我也想在我的软件包中添加一些概述信息。我喜欢Eclipse在键入/ ** 后为每个类或方法创建匹配的Doc Comment的存根。 Eclipse也有一种生成package.html文件的简单方法吗?

4 个解决方案

#1


Update 4 years later (Oct. 2013)

4年后更新(2013年10月)

javabeangrinder's answer (upvoted) mentions the following trick:

javabeangrinder的回答(upvoted)提到了以下技巧:

To create a package-info.java file in an existing package:

要在现有包中创建package-info.java文件:

  • Right click on the package where you want a package-info.java.
  • 右键单击要包含package-info.java的包。

  • Select new->package.
  • Check the Create package.info.java check box.
  • 选中Create package.info.java复选框。

  • Click on Finish
  • 单击Finish


Original answer (May 2009)

原始答案(2009年5月)

There is no template or wizard to easily create a package.html file.

没有模板或向导可以轻松创建package.html文件。

As mmyers said in his comment, since Java1.5, the correct file to create would be package-info.java.
That file can be used not only for javadocs, but also for package-level annotations (as illustrated here).

正如mmyers在评论中所说,自Java1.5以来,要创建的正确文件是package-info.java。该文件不仅可以用于javadoc,还可以用于包级注释(如此处所示)。

There is an opened Bug (#86168) for demanding a wizard for the creation of package-info.java (since the class wizard does not allow the package-info name).

有一个已打开的Bug(#86168),用于要求创建package-info.java的向导(因为类向导不允许包信息名称)。

The reflections on that topic are on since... 2005! The problem is that any solution should be implemented in a way that it also helps with 1.4 code.

自2005年以来,对该主题的反思已经开始了!问题是任何解决方案都应该以一种有助于1.4代码的方式实现。

The current workaround is to create a package-info.java as a text file.
From that point forward, package-info.java behaves as a normal Java class, and Eclipse places a package-info.class file in the output folder.
The Javadocs are correctly built using package-info.java, and not the package.html file.

当前的解决方法是将package-info.java创建为文本文件。从那时起,package-info.java就像普通的Java类一样,Eclipse将package-info.class文件放在输出文件夹中。使用package-info.java正确构建Javadoc,而不是package.html文件。

alt text http://jmdoudoux.developpez.com/cours/developpons/java/images/jaxb006.png

alt text http://jmdoudoux.developpez.com/cours/developpons/java/images/jaxb006.png


Note (in response to Strawberry's comment):

注意(回应Strawberry的评论):

  • bug 77451 (2004!, for package.html)
  • bug 77451(2004!,for package.html)

  • bug 163633 and bug 163926 (2006, for package-info.java)
  • bug 163633和bug 163926(2006,package-info.java)

both wish a preview of the package overview in package-info.java in the Javadoc view.

两者都希望在Javadoc视图中预览package-info.java中的包概述。

So far, no patch has been proposed/implemented.
There is simply not enough demands for that feature to be added.

到目前为止,尚未提出/实施任何补丁。对该功能的添加根本没有足够的要求。

#2


In eclipse

Since package-info.java isn't a valid identifier for a class it cannot be created as a class in Eclipse.

由于package-info.java不是类的有效标识符,因此无法在Eclipse中将其创建为类。

I found that when you create a new package there is a check box to check if you want a package-info.java.

我发现当你创建一个新包时,有一个复选框来检查你是否想要一个package-info.java。

To create a package-info.java file in an existing package:

要在现有包中创建package-info.java文件:

  1. Right click on the package where you want a package-info.java.
  2. 右键单击要包含package-info.java的包。

  3. Select new->package.
  4. Check the Create package.info.java check box.
  5. 选中Create package.info.java复选框。

  6. Click on Finish
  7. 单击Finish

#3


The JAutodoc plugin does a great job of this, as well as all your other documentation needs. Install and configure the plugin and right click the package and click JAutodoc > Add Package Javadoc

JAutodoc插件可以很好地完成这项工作,以及所有其他文档需求。安装并配置插件并右键单击该包,然后单击JAutodoc> Add Package Javadoc

There are configurations and templates available for the .java or .html package documentation.

有.java或.html包文档的配置和模板。

This plugin also does a great job of standardizing all your Javadoc needs, with a great deal of customization.

这个插件还可以很好地标准化所有Javadoc需求,并进行大量定制。

http://jautodoc.sourceforge.net/

#4


There's a plugin that seems to create package.html files. I haven't used it but someone landing here might find it useful.

有一个似乎创建package.html文件的插件。我没有使用它,但有人登陆这里可能会发现它很有用。

http://sourceforge.net/projects/package-javadoc/

#1


Update 4 years later (Oct. 2013)

4年后更新(2013年10月)

javabeangrinder's answer (upvoted) mentions the following trick:

javabeangrinder的回答(upvoted)提到了以下技巧:

To create a package-info.java file in an existing package:

要在现有包中创建package-info.java文件:

  • Right click on the package where you want a package-info.java.
  • 右键单击要包含package-info.java的包。

  • Select new->package.
  • Check the Create package.info.java check box.
  • 选中Create package.info.java复选框。

  • Click on Finish
  • 单击Finish


Original answer (May 2009)

原始答案(2009年5月)

There is no template or wizard to easily create a package.html file.

没有模板或向导可以轻松创建package.html文件。

As mmyers said in his comment, since Java1.5, the correct file to create would be package-info.java.
That file can be used not only for javadocs, but also for package-level annotations (as illustrated here).

正如mmyers在评论中所说,自Java1.5以来,要创建的正确文件是package-info.java。该文件不仅可以用于javadoc,还可以用于包级注释(如此处所示)。

There is an opened Bug (#86168) for demanding a wizard for the creation of package-info.java (since the class wizard does not allow the package-info name).

有一个已打开的Bug(#86168),用于要求创建package-info.java的向导(因为类向导不允许包信息名称)。

The reflections on that topic are on since... 2005! The problem is that any solution should be implemented in a way that it also helps with 1.4 code.

自2005年以来,对该主题的反思已经开始了!问题是任何解决方案都应该以一种有助于1.4代码的方式实现。

The current workaround is to create a package-info.java as a text file.
From that point forward, package-info.java behaves as a normal Java class, and Eclipse places a package-info.class file in the output folder.
The Javadocs are correctly built using package-info.java, and not the package.html file.

当前的解决方法是将package-info.java创建为文本文件。从那时起,package-info.java就像普通的Java类一样,Eclipse将package-info.class文件放在输出文件夹中。使用package-info.java正确构建Javadoc,而不是package.html文件。

alt text http://jmdoudoux.developpez.com/cours/developpons/java/images/jaxb006.png

alt text http://jmdoudoux.developpez.com/cours/developpons/java/images/jaxb006.png


Note (in response to Strawberry's comment):

注意(回应Strawberry的评论):

  • bug 77451 (2004!, for package.html)
  • bug 77451(2004!,for package.html)

  • bug 163633 and bug 163926 (2006, for package-info.java)
  • bug 163633和bug 163926(2006,package-info.java)

both wish a preview of the package overview in package-info.java in the Javadoc view.

两者都希望在Javadoc视图中预览package-info.java中的包概述。

So far, no patch has been proposed/implemented.
There is simply not enough demands for that feature to be added.

到目前为止,尚未提出/实施任何补丁。对该功能的添加根本没有足够的要求。

#2


In eclipse

Since package-info.java isn't a valid identifier for a class it cannot be created as a class in Eclipse.

由于package-info.java不是类的有效标识符,因此无法在Eclipse中将其创建为类。

I found that when you create a new package there is a check box to check if you want a package-info.java.

我发现当你创建一个新包时,有一个复选框来检查你是否想要一个package-info.java。

To create a package-info.java file in an existing package:

要在现有包中创建package-info.java文件:

  1. Right click on the package where you want a package-info.java.
  2. 右键单击要包含package-info.java的包。

  3. Select new->package.
  4. Check the Create package.info.java check box.
  5. 选中Create package.info.java复选框。

  6. Click on Finish
  7. 单击Finish

#3


The JAutodoc plugin does a great job of this, as well as all your other documentation needs. Install and configure the plugin and right click the package and click JAutodoc > Add Package Javadoc

JAutodoc插件可以很好地完成这项工作,以及所有其他文档需求。安装并配置插件并右键单击该包,然后单击JAutodoc> Add Package Javadoc

There are configurations and templates available for the .java or .html package documentation.

有.java或.html包文档的配置和模板。

This plugin also does a great job of standardizing all your Javadoc needs, with a great deal of customization.

这个插件还可以很好地标准化所有Javadoc需求,并进行大量定制。

http://jautodoc.sourceforge.net/

#4


There's a plugin that seems to create package.html files. I haven't used it but someone landing here might find it useful.

有一个似乎创建package.html文件的插件。我没有使用它,但有人登陆这里可能会发现它很有用。

http://sourceforge.net/projects/package-javadoc/