How to generate javadoc comments in Android Studio

前端 未结 16 2297
野的像风
野的像风 2020-12-04 10:01

Can I use shortcut keys in Android studio to generate javadoc comments?

If not, what is the easiest way to generate javadoc comments?

相关标签:
16条回答
  • 2020-12-04 10:18

    You can use eclipse style of JavaDoc comment generation through "Fix doc comment". Open "Preference" -> "Keymap" and assign "Fix doc comment" action to a key that you want.

    0 讨论(0)
  • 2020-12-04 10:18

    Here we can some something like this. And instead of using any shortcut we can write "default" comments at class/ package /project level. And modify as per requirement

       *** 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.
    

    Advantage is that, you can create comment block for all the methods at a time.

    0 讨论(0)
  • 2020-12-04 10:19

    Android Studio -> Preferences -> Editor -> Intentions -> Java -> Declaration -> Enable "Add JavaDoc"

    And, While selecting Methods to Implement (Ctrl/Cmd + i), on the left bottom, you should be seeing checkbox to enable Copy JavaDoc.

    0 讨论(0)
  • 2020-12-04 10:25

    Here is an example of a JavaDoc comment from Oracle:

    /**
     * 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;
            }
     }
    

    The basic format can be auto generated in either of the following ways:

    • Position the cursor above the method and type /** + Enter
    • Position the cursor on the method name and press Alt + Enter > click Add JavaDoc
    0 讨论(0)
  • 2020-12-04 10:25

    I'm not sure I completely understand the question, but a list of keyboard short cuts can be found here - Hope this helps!

    0 讨论(0)
  • 2020-12-04 10:27
    • Another way to add java docs comment is press : Ctrl + Shift + A >> show a popup >> type : Add javadocs >> Enter .

    • Ctrl + Shirt + A: Command look-up (autocomplete command name)

    0 讨论(0)
提交回复
热议问题