我能在Android Studio中使用快捷键生成Javadoc注释吗?
如果不能,那么最简单的生成Javadoc注释的方法是什么?
我能在Android Studio中使用快捷键生成Javadoc注释吗?
如果不能,那么最简单的生成Javadoc注释的方法是什么?
/**
,并按下Enter
键。这将生成Javadoc注释。/**
* @param a
* @param b
*/
public void add(int a, int b) {
//code here
}
欲了解更多信息,请查看链接 https://www.jetbrains.com/idea/features/javadoc.html
/**
* 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;
}
}
基本格式可以通过以下两种方式自动生成:
使用IDE的自动补全功能可以自动附加Javadoc注释。尝试输入/**
,然后按Enter以生成示例Javadoc注释。
/**
*
* @param action The action to execute.
* @param args The exec() arguments.
* @param callbackContext The callback context used when calling back into JavaScript.
* @return
* @throws JSONException
*/
您可以通过“修复文档注释”使用Eclipse风格的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.
好处是,您可以一次为所有方法创建评论块。
在Android Studio中,您不需要插件。在Mac上打开Android Studio,点击顶部栏中的Android Studio,选择“Preferences”,在列表中找到“File and Code Templates”,选择“includes”,构建它并将其持久保存在所有项目中。
添加Javadoc
/**
+ return