我可以在Android工作室使用快捷键来生成javadoc评论吗?
如果不是,生成javadoc注释的最简单方法是什么?
我可以在Android工作室使用快捷键来生成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
其他回答
下面是一个来自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
因为我们几乎都使用Kotlin,所以可以使用插件生成JavaDoc (KDoc)。在Android Studio中打开Settings(按Ctrl+Alt+S),选择Plugins并找到kdoc。我下载了KDoc-er,但你可以选择其中任何一个。然后重新启动Android Studio。
找到任何类/方法,键入/**,按Enter。你会得到一个简短的描述:
/**
* User data
*
* @property name
* @property avatar
* @property gender
* @constructor Create empty User data
*/
class UserData(...
ALT+SHIFT+G将为您的方法创建自动生成的注释(将光标放在方法的起始位置)。
要在方法声明之前输入/**键并按Enter生成注释。它将生成javadoc注释。
例子:
/**
* @param a
* @param b
*/
public void add(int a, int b) {
//code here
}
欲了解更多信息,请查看链接 https://www.jetbrains.com/idea/features/javadoc.html
生成javadoc注释使用 /** 你的文档 * /