为 Eclipse 中的现有代码生成 JavaDoc 注释

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2767340/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 14:42:50  来源:igfitidea点击:

Generating JavaDoc comments for existing code in Eclipse

javaeclipsecommentsjavadoc

提问by Amir Rachum

I know it's possible to generate comments for classes, interface, etc., in the wizard screen when creating them, but I haven't found an option to generate javadoc comments for an existing file. Is it possible?

我知道可以在创建类、接口等时在向导屏幕中为它们生成注释,但我还没有找到为现有文件生成 javadoc 注释的选项。是否可以?

Thanks.

谢谢。

回答by VonC

The command is "Add Javadoc Comment", or "Generate Element Comment" (Alt+Shift+J), and it is dependent on the oneelement currently selected.

命令是“ Add Javadoc Comment”或“ Generate Element Comment”(Alt+ Shift+ J),它取决于当前选择的一个元素。

It cannot be applied to a all file. So if you select the all class through the project explorer view, you won't be able to generate all the missing comments from there.

它不能应用于所有文件。因此,如果您通过项目资源管理器视图选择所有类,您将无法从那里生成所有缺失的注释。

But from the Project Explorer, as Vitalii Fedorenkomentions in the comments, it works (just tested it):

但是从项目资源管理器中,正如Vitalii Fedorenko在评论中提到的那样,它可以工作(只是对其进行了测试):

you should expand a class in the Package Explorer, select all elements and press Alt+Shift+J

您应该在 Package Explorer 中展开一个类,选择所有元素并按Alt+ Shift+J

http://img683.i_mageshack.us/img683/2263/eclipsegenjavadoc.png

http://img683.i_mageshack.us/img683/2263/eclipsegenjavadoc.png

回答by COME FROM

If you like to keep both hands on keyboard, then typing /**on the line before a method and pressing enter works too:

如果您喜欢将双手放在键盘上,那么/**在方法之前在行上输入并按 Enter 也可以:

/**[press enter here]
int avg(int a, int b) throws ArithmeticException {
    ...
}

-->

-->

/**
 * 
 * @param a
 * @param b
 * @return
 * @throws ArithmeticException
 */
int avg(int a, int b) throws ArithmeticException {
    ...
}

回答by maimoona

This https://stackoverflow.com/a/8223484/830945provides a very solution for this problem.

这个https://stackoverflow.com/a/8223484/830945为这个问题提供了一个很好的解决方案。

I myself have tested it and it works very well with eclipse. You just need to right click project, then choose required option. can be downloaded from http://jautodoc.sourceforge.net/index.html

我自己已经对其进行了测试,并且它与 eclipse 配合得很好。您只需要右键单击项目,然后选择所需的选项。可以从http://jautodoc.sourceforge.net/index.html下载