如何在Android Studio中生成javadoc注释

我可以在Android Studio中使用快捷键来生成javadoc注释吗?

如果不是,那么生成javadoc评论的最简单方法是什么?

我找不到任何直接生成javadoc注释的快捷方式。但如果在方法声明之前键入/** ,并按下Enter键,javadoc注释块将自动生成。

阅读这个更多的信息。

要发表评论,请在方法声明之前使用/ **并按“回车”键。 它会自动包含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 >单击添加JavaDoc 在这里输入图像说明

您可以通过“修复文档评论”来使用JavaDoc评论生成的eclipse样式。 打开“首选项” – >“键盘映射”,并将“修复文档注释”操作分配给所需的键。

您可以从Settings-> Plugin-> Browse repositories安装JavaDoc插件。

从下面的链接获取插件文档

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. 

好处是,你可以all the methods at a time.all the methods at a time.创build注释块all the methods at a time.

在Android Studio中,您不需要插件。在Mac上,只需打开Android Studio – >在顶部栏中单击Android Studio – >单击Prefrences – >在列表中findFile and Code Templates – > select includes – > build it并将坚持所有的项目

只需select(即单击)方法名称,然后使用组合键Alt + Enter,select“添加JavaDoc”

这假设你还没有在方法上面添加注释,否则“添加JavaDoc”选项将不会出现。

  • 另一种添加java文档注释的方法是按下: Ctrl + Shift + A >>显示一个popup窗口>>input:Add javadocs >> Enter。

  • Ctrl + Shirt + A:查找命令(自动完成命令名称)

在这里输入图像说明

我不确定我完全理解这个问题,但是可以在这里find键盘快捷键列表 – 希望这有助于!

只需在键盘映射设置中select键盘的Eclipse版本即可。 Android Studio中包含一个Eclipse键映射。

ALT + SHIFT + G将为您的方法创build自动生成的注释(将光标置于方法的起始位置)。