使用轻量级可以非常有效地完成此操作phpDocumentor 插件 http://www.vim.org/scripts/script.php?script_id=1355.
Edit 这是修改后的版本 http://www.vim.org/scripts/script.php?script_id=2980随着最近的发展。
Edit 这是 phpDocumentor 插件的版本 2 https://github.com/tobyS/pdv。它比上面两个链接更新。
将插件安装到您的$VIMFILES/plugin
目录并将其添加到您的 .vimrc 中:
" PHP documenter script bound to Control-P
autocmd FileType php inoremap <C-p> <ESC>:call PhpDocSingle()<CR>i
autocmd FileType php nnoremap <C-p> :call PhpDocSingle()<CR>
autocmd FileType php vnoremap <C-p> :call PhpDocRange()<CR>
The above binds phpDocumentor to Ctrlp in insert, normal, and visual modes. Place your cursor on a class, function, or variable definition, press Ctrlp, and the plugin will attempt to form a doc block based on the definition.
示例函数文档块:
/**
* testDocBlock
*
* @param mixed $param1
* @param mixed $param2
* @static
* @access public
* @return boolean
*/
public static function testDocBlock($param1, $param2) {
// Pressed Ctl-p while cursor was on the function definition line above...
}
示例类文档块
默认情况下,版权、版本、作者等包含在类文档块中。您可以修改插件以包含您自己的默认值:
/**
* TestClass
*
* @package
* @version $id$
* @copyright
* @author Michael <[email protected] /cdn-cgi/l/email-protection>
* @license
*/
class TestClass {
}
完整的抽象类示例:
<?php
/**
* TestClass
*
* @abstract
* @package
* @version $id$
* @copyright
* @author Michael <[email protected] /cdn-cgi/l/email-protection>
* @license
*/
abstract class TestClass {
/**
* publicProp
*
* @var string
* @access public
*/
public $publicProp;
/**
* privateProp
*
* @var string
* @access private
*/
private $privateProp;
/**
* testDocBlock
*
* @param string $param1
* @param string $param2
* @static
* @access public
* @return boolean
*/
public static function testDocBlock($param1, $param2) {
// code here...
}
}
?>