FANDOM


m (PHPdoc: Use JCommenter.vim for php-scripts moved to Automatically generate PHPdoc comments: Page moved by JohnBot to improve title)
(Example 1)
 
(5 intermediate revisions by one user not shown)
Line 1: Line 1:
 
{{review}}
 
{{review}}
{{Tip
+
{{TipImported
 
|id=407
 
|id=407
|title=PHPdoc: Use JCommenter.vim for php-scripts
+
|previous=406
|created=January 18, 2003 23:57
+
|next=408
  +
|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
|text=
+
|category1=Automated Text Insertion
Use JCommenter.vim for php-scripts:
+
|category2=PHP
  +
}}
  +
Use JCommenter.vim for php-scripts:
   
{{script|id=20|text=jcommenter.vim}} : A script for automatically generating JavaDoc comments
+
{{script|id=20|text=jcommenter.vim}} : A script for automatically generating JavaDoc comments
   
PHPdoc is an imitation of JAVAdoc.
+
PHPdoc is an imitation of JAVAdoc. The syntax between the two languages is very close, see the examples below:
   
The syntax between the two languages is very close, see the examples below:
+
===Example 1===
  +
A PHP function.
   
===Example 1: ===
+
<pre>
  +
function serialize_it($something) {
  +
$person = serialize($something);
  +
return $person;
  +
}
  +
</pre>
   
You have the PHP-function:
+
Put the cursor on the first line and type <code>:call JCommentWriter()<CR></code>
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>
 
   
 
You get:
 
You get:
/**
 
*
 
*
 
* @param $something
 
* @return
 
*/
 
function serialize_it($something) {
 
$personen = serialize($something);
 
return $personen;
 
}
 
   
===Example 2: ===
+
<pre>
  +
/**
  +
*
  +
*
  +
* @param $something
  +
* @return
  +
*/
  +
function serialize_it($something) {
  +
$personen = serialize($something);
  +
return $personen;
  +
}</pre>
   
You have the PHP-class:
+
class submenu {
 
...
 
}
 
   
Put the cursor on the first line and call <tt>:call JCommentWriter()&lt;CR&gt; </tt>
+
===Example 2===
  +
A PHP class.
  +
  +
<pre>
  +
class submenu {
  +
...
  +
}
  +
</pre>
  +
  +
Put the cursor on the first line and type <code>:call JCommentWriter()<CR></code>
   
 
You get:
 
You get:
/**
 
*
 
*
 
* @author
 
* @version
 
*/
 
class submenu {
 
...
 
}
 
   
===Example 3: ===
+
<pre>
  +
/**
  +
*
  +
*
  +
* @author
  +
* @version
  +
*/
  +
class submenu {
  +
...
  +
}
  +
</pre>
   
For a class-variable you get:
+
===Example 3===
/**
+
For a class-variable you get:
*
 
*/
 
var $urls;
 
   
===Note: ===
+
<pre>
It does not work if you have = '' like in
+
/**
function serialize_it($something = '') {}
+
*
  +
*/
  +
var $urls;
  +
</pre>
   
But I think jscript.vim can be adapted for the use with PHP.
+
===Note===
  +
It does not work if you have <code>= ''</code> like in
  +
function serialize_it($something = '') {}
   
Klaus
+
But I think jscript.vim can be adapted for the use with PHP.
}}
 
   
== Comments ==
+
==Comments==
<!-- parsed by vimtips.py in 0.629234 seconds-->
 
[[Category:PHP]]
 
[[Category:Automated_Text_Insertion]]
 

Latest revision as of 07:38, January 21, 2015

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 1Edit

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 2Edit

A PHP class.

class submenu {
 ...
}

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

You get:

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

Example 3Edit

For a class-variable you get:

/**
 *
 */
var $urls;

NoteEdit

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.

CommentsEdit

Community content is available under CC-BY-SA unless otherwise noted.