我可以在Android工作室使用快捷键来生成javadoc评论吗?
如果不是,生成javadoc注释的最简单方法是什么?
我可以在Android工作室使用快捷键来生成javadoc评论吗?
如果不是,生成javadoc注释的最简单方法是什么?
当前回答
下面是一个来自Oracle的JavaDoc注释示例:
/**
* Returns an Image object that can then be painted on the screen.
* The url argument must specify an absolute {@link URL}. The name
* argument is a specifier that is relative to the url argument.
* <p>
* This method always returns immediately, whether or not the
* image exists. When this applet attempts to draw the image on
* the screen, the data will be loaded. The graphics primitives
* that draw the image will incrementally paint on the screen.
*
* @param url an absolute URL giving the base location of the image
* @param name the location of the image, relative to the url argument
* @return the image at the specified URL
* @see Image
*/
public Image getImage(URL url, String name) {
try {
return getImage(new URL(url, name));
} catch (MalformedURLException e) {
return null;
}
}
基本格式可以通过以下两种方式自动生成:
将光标置于方法上方,并键入/** + Enter 将光标定位在方法名上,按Alt + Enter >,单击Add JavaDoc
其他回答
简单地选择(即点击)方法名称,然后使用Alt+Enter组合键,选择“添加JavaDoc”
这假设您还没有在方法上面添加注释,否则“Add JavaDoc”选项将不会出现。
您可以通过“Fix doc comment”使用eclipse风格的JavaDoc注释生成。 打开“Preference”->“Keymap”,并将“Fix doc comment”动作分配给一个你想要的键。
生成javadoc注释使用 /** 你的文档 * /
下面是一个来自Oracle的JavaDoc注释示例:
/**
* Returns an Image object that can then be painted on the screen.
* The url argument must specify an absolute {@link URL}. The name
* argument is a specifier that is relative to the url argument.
* <p>
* This method always returns immediately, whether or not the
* image exists. When this applet attempts to draw the image on
* the screen, the data will be loaded. The graphics primitives
* that draw the image will incrementally paint on the screen.
*
* @param url an absolute URL giving the base location of the image
* @param name the location of the image, relative to the url argument
* @return the image at the specified URL
* @see Image
*/
public Image getImage(URL url, String name) {
try {
return getImage(new URL(url, name));
} catch (MalformedURLException e) {
return null;
}
}
基本格式可以通过以下两种方式自动生成:
将光标置于方法上方,并键入/** + Enter 将光标定位在方法名上,按Alt + Enter >,单击Add JavaDoc
这里我们可以做一些这样的东西。 而不是使用任何快捷方式,我们可以在类/包/项目级别写“默认”注释。并根据需求进行修改
*** Install JavaDoc Plugin ***
1.Press shift twice and Go to Plugins.
2. search for JavaDocs plugin
3. Install it.
4. Restart Android Studio.
5. Now, rightclick on Java file/package and goto
JavaDocs >> create javadocs for all elements
It will generate all default comments.
优点是,您可以一次为所有方法创建注释块。