如何在Android Studio中生成javadoc注释

qin*_*zou 191 javadoc android-studio

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

如果没有,生成javadoc注释的最简单方法是什么?

Dou*_*ouO 370

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

阅读本文以获取更多信息.

  • 当然它有快捷方式:在方法/构造函数名称上的位置,然后按alt + enter,从菜单中选择生成javadoc (19认同)
  • 遗憾的是,这对于为类,字段等生成javadoc注释也不起作用.如果它从可自定义的模板生成javadoc,那就更好了. (7认同)
  • @DouO现在链接返回404错误 (4认同)
  • @Ewoks [不起作用](https://i.imgur.com/Fnuwk0K.png) 对我来说。 (3认同)

小智 107

/**在方法声明之前按下注释类型键并按Enter.它将生成javadoc评论.

例:

/**
* @param a
* @param b
*/

public void add(int a, int b) {
    //code here
}
Run Code Online (Sandbox Code Playgroud)

有关更多信息,请访问https://www.jetbrains.com/idea/features/javadoc.html链接

  • @satheeshwaran - 真的吗?它与DouO(原始答案)的答案相同,只不过它有一个例子.连链接都是副本.该示例应该刚刚添加到原始答案中. (4认同)
  • @satheeshwaran - 为了它的价值,我可以看到只要看到评论的例子(在答案中)是有用的,当一个人想快速回答;-) (3认同)

Sur*_*gch 34

以下是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;
        }
 }
Run Code Online (Sandbox Code Playgroud)

基本格式可以通过以下任一方式自动生成:

  • 将光标定位在方法上方并键入/**+Enter
  • 将光标定位在方法名称上,然后按Alt+ Enter>单击"添加JavaDoc" 在此输入图像描述


dar*_*win 16

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

从以下链接获取插件文档

JavaDoc插件文档

在此输入图像描述


Koh*_*ami 10

您可以通过"修复文档注释"使用eclipse风格的JavaDoc注释生成.打开"首选项" - >"键盘映射",并将"修复文档注释"操作分配给您想要的键.


Mr.*_*dia 9

在这里,我们可以这样的东西.而不是使用任何快捷方式,我们可以在类/包/项目级别编写"默认"注释.并根据要求进行修改

   *** 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.
Run Code Online (Sandbox Code Playgroud)

优点是,您可以为其创建注释块 all the methods at a time.


Kul*_*mar 7

可以使用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
 */
Run Code Online (Sandbox Code Playgroud)


小智 5

在Android Studio中,您不需要插件.在Mac上只需打开Android Studio - >单击顶部栏中的Android Studio - >单击Prefrences - >在列表中查找文件和代码模板 - >选择包含 - >构建它并将坚持你的所有项目