RenniePet
RenniePet

Reputation: 11658

How to insert XML comments in Java code in IntelliJ IDEA?

Maybe I'm missing something obvious, but I can't find a way to enable insertion of XML comments in Java code using the IntelliJ IDEA editor (v. 12 community edition).

I'm talking about comments like this:

/// <summary>
/// Encrypts plaintext using AES 128bit key and a Chain Block Cipher and returns a base64 encoded string
/// </summary>
/// <param name="plainText">Plain text to encrypt</param>
/// <param name="key">Secret key</param>
/// <returns>Base64 encoded string</returns>
public String encrypt(String plainText, String key) throws ...

Upvotes: 6

Views: 6029

Answers (2)

Sergej Panic
Sergej Panic

Reputation: 839

Place keyboard caret above your method. Type /** then hit ENTER. Intellj will create a template JavaDoc comment to which you can add a description of parameters and return value , for example:

/**
 *  Encrypts plaintext using AES 128bit key and a Chain Block Cipher and returns a base64 encoded string  
 * 
 * @param plainText  Plain text to encrypt
 * @param key  Secret key
 * @return Base64 encoded string
 */
public String encrypt(String plainText, String key) throws ...

To see a pop-up window with the formatted comment text place the caret inside /** ... */ and type Ctrl+Q

Upvotes: 7

Sergej Panic
Sergej Panic

Reputation: 839

Use {@code ... } Javadoc tag.
Look here: http://blog.smartkey.co.uk/2008/08/adding-xml-to-javadoc-comments/

Upvotes: 0

Related Questions