phpDocument是一个通用的生成PHP文档的工具,他本身也是用PHP写的,跟JAVADoc有些相似,但他有不同于PHPDoc,他比PHPDOC要快,而且能够解析的PHP范围更广,他本身包含了11个摸版,并且还能够生成WINDOWS的chm格式,或PDF、XML
DocBook等。
首先如果phpDocument能根据PHP程序生成文档,那么PHP的注释必须按照标准格式书写,下面举几个例子;
简要说明:
注释格式(注意 前面是两个**)
/**
* 注释内容
*/
方法声明
/**
* A sample function docblock
* @global string document the fact that this function uses $_myvar
* @staticvar integer $staticvar this is actually what is returned
* @param string $param1 name to declare
* @param string $param2 value of the name
* @return integer
*/
具体怎么写注释大家可以注意看那个示例地址,这里想介绍的是怎样生成文档
phpDocument的安装
在pear下安装phpDocumentor是一件极其简单的事情,只需要在cmd窗口中cd 到php安装目录下,然后输入
Pear install phpDocumentor
(也可以直接下载:http://pear.php.net/package/PhpDocumentor/download
然后在PHP环境下不同的操作系统下使用包中的 phpdoc.bat phpdoc
)
在phpdoc.bat所在目录下,输入
Phpdoc –h
会得到一个phpDocumentor的详细参数列表。
我们从其中选出几个常用的来看看:
我们从其中选出几个常用的来看看:
命令解释 ?>
-f
要进行分析的文件名,多个文件用逗号分割
-d
要分析的目录,多个目录用逗号分割
-t
生成的文档的存放路径
-o
输出的文档格式,结构为输出格式:转换器名:模版目录,例如:HTML:frames:phpedit
使用示例
Phpdoc -d “C:\Program
Files\EasyPHP5\php\PEAR\PHPUnit2” -t “C:\Program
Files\EasyPHP5\php\phpunit2doc” -o
“HTML:frames:phpedit”