Vim Tips Wiki
m (Category: PHP)
m (Added to Automated_Text_Insertion Category + code reformatted)
Line 11: Line 11:
 
Use JCommenter.vim for php-scripts:
 
Use JCommenter.vim for php-scripts:
   
 
{{script|id=20|text=jcommenter.vim}} : A script for automatically generating JavaDoc comments
 
 
jcommenter.vim : A script for automatically generating JavaDoc comments
 
 
http://vim.sourceforge.net/script.php?script_id=20
 
 
 
   
 
PHPdoc is an imitation of JAVAdoc.
 
PHPdoc is an imitation of JAVAdoc.
   
The syntax between the two languages is very close,
+
The syntax between the two languages is very close, see the examples below:
   
 
===Example 1: ===
see the examples below:
 
 
 
 
Example 1:
 
   
 
You have the PHP-function:
 
You have the PHP-function:
 
function serialize_it($something) {
 
$person = serialize($something);
 
return $person;
 
}
   
 
Put the cursor on the first line and call <tt>:call JCommentWriter()&lt;CR&gt;</tt>
function serialize_it($something) {
 
   
 
You get:
$person = serialize($something);
 
 
/**
 
*
 
*
 
* @param $something
 
* @return
 
*/
 
function serialize_it($something) {
 
$personen = serialize($something);
 
return $personen;
 
}
   
 
===Example 2: ===
return $person;
 
 
}
 
 
 
 
Put the cursor on the first line and call :call JCommentWriter()&lt;CR&gt;
 
 
 
 
You get
 
 
/**
 
 
*
 
 
*
 
 
* @param $something
 
 
* @return
 
 
*/
 
 
function serialize_it($something) {
 
 
$personen = serialize($something);
 
 
return $personen;
 
 
}
 
 
 
 
Example 2:
 
   
 
You have the PHP-class:
 
You have the PHP-class:
 
class submenu {
 
...
 
}
   
 
Put the cursor on the first line and call <tt>:call JCommentWriter()&lt;CR&gt; </tt>
class submenu {
 
   
 
You get:
...
 
 
/**
 
*
 
*
 
* @author
 
* @version
 
*/
 
class submenu {
 
...
 
}
   
 
===Example 3: ===
}
 
 
 
 
Put the cursor on the first line and call :call JCommentWriter()&lt;CR&gt;
 
 
 
 
You get
 
 
/**
 
 
*
 
 
*
 
 
* @author
 
 
* @version
 
 
*/
 
 
class submenu {
 
 
...
 
 
}
 
 
 
 
Example 3:
 
   
 
For a class-variable you get:
 
For a class-variable you get:
 
/**
 
*
 
*/
 
var $urls;
   
 
===Note: ===
/**
 
 
*
 
 
*/
 
 
var $urls;
 
 
 
 
Note:
 
 
 
It does not work if you have = '' like in
 
It does not work if you have = '' like in
 
function serialize_it($something = '') {}
 
function serialize_it($something = '') {}
 
 
 
   
 
But I think jscript.vim can be adapted for the use with PHP.
 
But I think jscript.vim can be adapted for the use with PHP.
 
 
   
 
Klaus
 
Klaus
Line 139: Line 79:
 
<!-- parsed by vimtips.py in 0.629234 seconds-->
 
<!-- parsed by vimtips.py in 0.629234 seconds-->
 
[[Category:PHP]]
 
[[Category:PHP]]
  +
[[Category:Automated_Text_Insertion]]

Revision as of 18:50, 23 July 2007

Previous TipNext Tip

Tip: #407 - Automatically generate PHPdoc comments

Created: January 18, 2003 23:57 Complexity: intermediate Author: Klaus Horsten <email.5--AT--gmx.net> Version: 6.0 Karma: 16/4 Imported from: Tip#407

Use JCommenter.vim for php-scripts:

jcommenter.vim : A script for automatically generating JavaDoc comments

PHPdoc is an imitation of JAVAdoc.

The syntax between the two languages is very close, see the examples below:

Example 1:

You have the PHP-function:

function serialize_it($something) { 
  $person = serialize($something); 
  return $person; 
} 

Put the cursor on the first line and call :call JCommentWriter()<CR>

You get:

/** 
 * 
 * 
 * @param $something 
 * @return 
 */ 
function serialize_it($something) { 
  $personen = serialize($something); 
  return $personen; 
} 

Example 2:

You have the PHP-class:

class submenu { 
 ... 
} 

Put the cursor on the first line and call :call JCommentWriter()<CR>

You get:

/** 
 * 
 * 
 * @author 
 * @version 
 */ 
class submenu { 
 ... 
} 

Example 3:

For a class-variable you get:

/** 
 * 
 */ 
var $urls; 

Note:

It does not work if you have = like in

function serialize_it($something = ) {} 

But I think jscript.vim can be adapted for the use with PHP.

Klaus

Comments