Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to customize generated javadoc stubs?

In Netbeans when you type /** above a method it generates a javadoc stub:

/**
 * 
 * @param 
 * @return 
 */

How do you customize the generated text? I would like a custom javadoc stub like:

/**  Author = {author}
 *  
 * My custom text  
 * 
 * @param 
 * @return 
 */

Note: this is on a method, not the class which uses the class templates.

search terms: netbeans javadoc template stub custom autocomplete

like image 881
fishjd Avatar asked Feb 05 '13 17:02

fishjd


1 Answers

This won't replace the functioning of /** but it'll allow you an alternative.

  • Go into Tools, Options,
  • Click on Edit, Code Templates tab,
  • From the language pull-down, make sure Java is selected,
  • Click New,
  • Type in an abbreviation of your choice (I used jdt for javadoc template),
  • Click OK,
  • Under expanded text, type in the javadoc comment how you want it. Note: one annoying thing is, you have to have an extra enter at the end of lines with words, or else it won't move the next word down to the next line.

For example, if you put in this:

/**
 * @author
 * 
 * @param
 * @return
 */

It'll output this:

/**
 * @author
 * 
 * @param @return
 */

But if you input this:

/**
 * @author
 * 
 * @param
 *
 * @return
 */

It'll output:

/**
 * @author
 * 
 * @param
 *
 * @return
 */

Kind of weird. Anyway, once you've typed that in, look at the Expand Template on: button and see if it is set on tab or enter or whatever. That part is your choice. However you want to activate the template. Click OK.

In your document, go to where you want to insert your preformatted comment, and instead of typing /** type in jdt then do whatever the Expand template action was (tab, enter, etc) and your comment will appear.

like image 161
Jeff Hawthorne Avatar answered Nov 03 '22 02:11

Jeff Hawthorne