Can I add JavaDoc to a package easily with Eclipse?

青春壹個敷衍的年華 提交于 2019-12-03 00:57:56
VonC

Update 4 years later (Oct. 2013)

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

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

  • Right click on the package where you want a package-info.java.
  • Select new->package.
  • Check the Create package.info.java check box.
  • Click on Finish

Original answer (May 2009)

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

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).

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).

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.

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.


(source: developpez.com)


Note (in response to Strawberry's comment):

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

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

In eclipse

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

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

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

  1. Right click on the package where you want a package-info.java.
  2. Select new->package.
  3. Check the Create package.info.java check box.
  4. Click on Finish

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

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

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

http://jautodoc.sourceforge.net/

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

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

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