Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I customize NetBeans PHP auto DocBlock for methods and attributes?

After I create a method I use /**<enter> to generate the DocBlock. It auto fills the @param and @return for that function. Example:

/**
 *
 * @param type $str
 * @return type 
 */
public function strlen($str){
    return strlen($str);
}

How can I customize the block being generated so that it also fills in the @author and end up with this after /**<enter>

/**
 *
 * @param type $str
 * @return type 
 * @author John Doe <[email protected]>
 */
public function strlen($str){
    return strlen($str);
}

Thanks

like image 736
bxfckrclooo Avatar asked May 07 '11 17:05

bxfckrclooo


3 Answers

There may be a better way to do this, but here's what I've used: under Tools > Options > Editor > Code Templates, there are some predefined combos for generating code quickly. One of the default templates in 7.0 is:

vdoc<tab> 

This generates a pseudo-docblock and the variable definition. You can replace this and add new ones that expand into whatever text you want, much like vim abbreviations. You can find more on this on the Netbeans documentation site:

http://netbeans.org/kb/docs/php/code-templates.html#using-templates

like image 178
Bryan Agee Avatar answered Oct 05 '22 15:10

Bryan Agee


I believe the answer you're looking for will be found here: phpDocumentor Tutorial

I think you'll want to look at the --customtags Command-line switch.

So most likely, when you go to Tools -> Options -> "PHP" -> "PHPDoc", you can add that --customtags command-line switch into the PHPDoc script line.

I haven't attempted this personally, but I have been playing around with the idea of using NetBeans in combination with DocBlocks and PHPDocumentor to "automagically" create a good amount of usable documentation without being too strenuous on the rest of the coders. ;-)

There's a nice video tutorial about setting up NetBeans to work with PHPDocumentor available here: Generating PHP Documentation With NetBeans IDE 7.0

like image 23
russsaidwords Avatar answered Oct 05 '22 13:10

russsaidwords


To enable proper @author tag autocompletion, just go to: Tools->Templates->PHP->PHP Class, press the "Settings" button and uncomment the line starting with #user=. Now you're able to edit the name and email, which are passed to your Class comment.

like image 21
zinovyev Avatar answered Oct 05 '22 13:10

zinovyev