Vim Tips Wiki
No edit summary
 
(Change <tt> to <code>, perhaps also minor tweak.)
(7 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
{{review}}
 
{{review}}
  +
{{TipImported
{{Tip
 
 
|id=407
 
|id=407
  +
|previous=406
|title=PHPdoc: Use JCommenter.vim for php-scripts
 
  +
|next=408
|created=January 18, 2003 23:57
+
|created=2003
 
|complexity=intermediate
 
|complexity=intermediate
|author=Klaus Horsten <email.5--AT--gmx.net>
+
|author=Klaus Horsten
 
|version=6.0
 
|version=6.0
 
|rating=16/4
 
|rating=16/4
  +
|category1=Automated Text Insertion
|text=
 
  +
|category2=PHP
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
   
 
PHPdoc is an imitation of JAVAdoc. The syntax between the two languages is very close, see the examples below:
   
 
===Example 1===
jcommenter.vim : A script for automatically generating JavaDoc comments
 
  +
A PHP function.
   
  +
<pre>
http://vim.sourceforge.net/script.php?script_id=20
 
 
function serialize_it($something) {
 
$person = serialize($something);
 
return $person;
 
}
  +
</pre>
   
 
Put the cursor on the first line and type <code>:call JCommentWriter()<CR></code>
   
 
You get:
   
  +
<pre>
PHPdoc is an imitation of JAVAdoc.
 
 
/**
 
*
 
*
 
* @param $something
 
* @return
 
*/
 
function serialize_it($something) {
 
$personen = serialize($something);
 
return $personen;
 
}
  +
</pre>
   
 
===Example 2===
The syntax between the two languages is very close,
 
  +
A PHP class.
   
  +
<pre>
see the examples below:
 
 
class submenu {
 
...
 
}
  +
</pre>
   
 
Put the cursor on the first line and type <code>:call JCommentWriter()<CR></code>
   
 
You get:
   
  +
<pre>
Example 1:
 
 
/**
 
*
 
*
 
* @author
 
* @version
 
*/
 
class submenu {
 
...
 
}
  +
</pre>
   
 
===Example 3===
You have the PHP-function:
 
 
For a class-variable you get:
   
  +
<pre>
function serialize_it($something) {
 
 
/**
  +
*
 
*/
 
var $urls;
  +
</pre>
   
  +
===Note===
$person = serialize($something);
 
 
It does not work if you have <code>= ''</code> like in
 
function serialize_it($something = '') {}
   
 
But I think jscript.vim can be adapted for the use with PHP.
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:
 
 
class submenu {
 
 
...
 
 
}
 
 
 
 
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:
 
 
/**
 
 
*
 
 
*/
 
 
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 ==
+
==Comments==
<!-- parsed by vimtips.py in 0.629234 seconds-->
 

Revision as of 05:29, 13 July 2012

Tip 407 Printable Monobook Previous Next

created 2003 · complexity intermediate · author Klaus Horsten · version 6.0


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

A PHP function.

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

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

You get:

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

Example 2

A PHP class.

class submenu {
 ...
}

Put the cursor on the first line and type :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.

Comments