Java 在 Eclipse 中自动生成函数注释
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4033190/
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
Autogenerate function comments in Eclipse
提问by devnull
How to autogenerate xml based function header comments (@param etc) in Eclipse. Is there an equivalent of "///" shortcut in Visual Studio.
如何在 Eclipse 中自动生成基于 xml 的函数头注释(@param 等)。Visual Studio 中是否有等效于“///”的快捷方式。
采纳答案by Nivas
In the line just before the method definition, type /**
and hit enter.
在方法定义之前的行中,键入/**
并按回车键。
In the IDE, type /**
just before the method and hit enter.
Eclipse will autogenerate the Javadoc tags and the end */
在 IDE 中,/**
在方法之前键入并按 Enter。Eclipse 将自动生成 Javadoc 标签和结尾*/
type /** here and his enter, eclipse will generate the javadoc tags and the end */
public void setName(String name)
{
...
}
回答by gulbrandr
http://jautodoc.sourceforge.net/
http://jautodoc.sourceforge.net/
JAutodoc is an Eclipse Plugin for automatically adding Javadoc and file headers to your source code. It optionally generates initial comments from element name by using Velocity templates for Javadoc and file headers.
JAutodoc 是一个 Eclipse 插件,用于自动将 Javadoc 和文件头添加到您的源代码中。它可以选择使用 Javadoc 和文件头的 Velocity 模板从元素名称生成初始注释。
回答by Faizan S.
You can do this by clicking ALT+Shift+J
inside the method/class. | It's not XML Based though, but you can generate JavaDoc by clicking Project->Generate JavaDoc...
in the menubar.
您可以通过ALT+Shift+J
在方法/类内部单击来执行此操作。| 虽然它不是基于 XML 的,但是您可以通过单击Project->Generate JavaDoc...
菜单栏来生成 JavaDoc 。
回答by Andrew
You can specify what is autogenerated in Eclipse by going to Window->Preferences
您可以通过转到 Window->Preferences 来指定在 Eclipse 中自动生成的内容
Under, Java -> Code Style -> Code Templates; is the list of what comments get put where. You can google for the syntax of how to insert the different param names and other constants so that you can generate whatever comment you wish, be it Javadoc or other.
在下,Java -> Code Style -> Code Templates;是评论放在哪里的列表。您可以谷歌搜索如何插入不同参数名称和其他常量的语法,以便您可以生成任何您想要的评论,无论是 Javadoc 还是其他。
As Nivas said, typing /** then hitting enter will auto insert a the comment.
正如 Nivas 所说,输入 /** 然后按 Enter 将自动插入评论。