原创 PHP文档工具收藏

新一篇: Windows 环境下的PHP5 与 Apache 服务器的配置 | 旧一篇: 用ActivePHP打造版本管理系统

PHP文档工具

——phpDocumentor

Easy@phpe /

 

写文档是一项乏味却不得不做的工作,而编写API级的文档更是意味着大量的重复劳动和难以保持的一致性。这里我们要推荐给大家的,是支持PHP5语法分析的文档工具——phpDocumentor

使用phpDocumentor不仅可以自动从代码中提取出函数和方法定义,还可以自动处理各个class之间的关系,并据此生成class tree。你还可以选择将文档生成htmlchm或者pdf。有了phpDocumentor,文档工作变得轻松了很多。

 

安装phpDocumentor

pear下安装phpDocumentor是一件极其简单的事情,只需要在cmd窗口中cd php安装目录下,然后输入

Pear install phpDocumentor

Pear就会自己下载并完成phpDocumentor的安装。

phpDocumentor成功安装后,php安装目录下会多出来一个phpdoc.bat。这个文件就是我们用来生成文档的批处理文件了。

<? 相关知识 ?>

phpDocumentorphpDoc的升级版本,是专门为支持php5语法而重写的文档工具,当你的php版本为5时,运行phpDoc.bat,它会自动去调用phpDocumentor。所以文章中的提到的phpDocphpDocumentor实际上是相同的。

 

phpdoc.bat所在目录下,输入

Phpdoc –h

会得到一个phpDocumentor的详细参数列表。

我们从其中选出几个常用的来看看:

<? 命令解释 ?>

-f

要进行分析的文件名,多个文件用逗号分割

-d

要分析的目录,多个目录用逗号分割

-t

生成的文档的存放路径

-o

输出的文档格式,结构为输出格式:转换器名:模版目录,例如:HTML:frames:phpedit

 

我们会用到的就这几个了,其他的命令请大家阅读help的提示信息。

 

试用phpDocumentor

  下面我们就以pear中的phpUnit2为例,演示一下如何使用phpDocumentor来生成文档。

  首先,把我们需要的参数确定下来:

<? 命令参数 ?>

-d

C:\Program Files\EasyPHP5\php\PEAR\PHPUnit2

-t

C:\Program Files\EasyPHP5\php\phpunit2doc

-o

HTML:frames:phpedit

根据上边的参数,我们组合出下边的命令:

Phpdoc -d  C:\Program Files\EasyPHP5\php\PEAR\PHPUnit2” -t “C:\Program Files\EasyPHP5\php\phpunit2doc” -o “HTML:frames:phpedit”

运行上边的命令后,phpDocumentor开始解析源文件并输出工作信息。

命令运行完成后,我们的文档就已经生成好了。 进入我们指定的目标目录,用浏览器打开index.html就可以看见生成的文档了。  文档界面由frame分成了三个部分,左上是包信息,左下是导航信息,右边则是详细的信息呈现页。

上边的图很清楚地描述出了文档的内容:

索引、函数列表、类列表、文件列表和子包。

点击上边的class(es)链接,我们可以清晰的看见整个包的class tree

我们点击其中一个class,就进入了class的描述页面。

Class描述页面主要包含以下几方面内容:

 

l          描述:版权、作者、类层次等

l          类变量

l          类常量

l          方法

l          继承的变量

l          继承的方法:非常有用的一个功能

 

 

怎么样,是不是很详细呢?如果要生成chm,可以把前边的-o参数改为”CHM:default: default”,这样phpDocumentor会为你生成好chm项目文件,只要用微软的chm工具进行编译就可以得到可用的chm文件了。

 

phpDocumentor为自己的代码生成文档

  虽然phpDocumentor可以自动从代码中分析出一些信息,但是,要形成一份详尽的文档还是需要我们在编码中进行配合的。为了让phpDocumentor读懂我们的代码,我们需要注意一些编码规范和在注释中增加一些tag

 

<? Tags ?>

@author 

作者信息

@const

define定义的常量

@deprecate

不建议使用的API

@global

全局变量

@package

包信息

@param

函数参数

@return

返回值

@see

参考函数

@since

引入时间

@static

静态变量

@var

类成员变量

 

这里只是简单的列出了常用的一些Tag,大家可以阅读phpDocumentor的文档,里边有非常详细的编码规范。关于phpDocumento就介绍到这里,希望大家都能好好利用这个工具来规范自己的文档。

 

PSphpDocumentor也有Web界面的,你可以访问http://phpdoc.org获取Web版本。Web版本的安装很简单,直接放到web可以访问的目录就可以运行了。

 

<? 环境要求 ?>

PHP5.0.0

OS: 平台独立,本文演示OSwindows

 

发表于 @ 2004年08月06日 13:40:00|评论(loading...)|编辑

新一篇: Windows 环境下的PHP5 与 Apache 服务器的配置 | 旧一篇: 用ActivePHP打造版本管理系统

评论

#6600 Nokia Ringtone 发表于2006-11-21 17:31:00  IP: 131.114.190.*
TrackBack来自《6600 Nokia Ringtone》

<a href="http://www.bloggerblast.com/rings/">6600 Nokia Ringtone</a>
#Cingular Music Ringtone 发表于2006-11-26 16:34:00  IP: 195.245.212.*
TrackBack来自《Mas Airline Ticket》

<a href="http://digbig.com/4pjpy">Cingular Music Ringtone</a>-<a href="http://url.vg/seaarch/dbbf8f">Mas Airline Ticket</a>
#Online Prescription Tramadol 发表于2006-11-26 19:26:00  IP: 212.122.76.*
TrackBack来自《Ringtone From Cingular》

<a href="http://url.vg/seaarch/1724a1">Ringtone From Cingular</a>-<a href="http://url.vg/seaarch/e14e57">Online Prescription Tramadol</a>
#Bet Nba Basketball 发表于2006-11-26 22:14:00  IP: 210.245.22.*
TrackBack来自《Tramadol Saturday Delivery》

<a href="http://url.vg/seaarch/eb7e75">Bet Nba Basketball</a>-<a href="http://url.vg/topmeds10/c8c71f">Tramadol Saturday Delivery</a>
#Oliver Gettz 发表于2006-11-28 23:30:00  IP: 81.169.147.*
TrackBack来自《Oliver Gettz》

Very good site, greate content !!
#Oliver Gettz 发表于2006-11-28 23:21:00  IP: 212.203.95.*
TrackBack来自《Oliver Gettz》

Very good site, greate content !!
#Kristen Klosa 发表于2006-11-29 02:24:00  IP: 203.144.144.*
TrackBack来自《Kristen Klosa》

Hello admin, nice site ! Good content, eautiful design, thank !
#Merlin Yops 发表于2006-11-29 02:35:00  IP: 192.114.168.*
TrackBack来自《Merlin Yops》

I love you so much! Great place to visit!
#carisoprodol 发表于2006-11-29 11:23:00  IP: 59.120.5.*
TrackBack来自《carisoprodol》

<a href="http://ebbs.ru/KU">carisoprodol</a>
#Travis Vytter 发表于2006-11-29 03:10:00  IP: 210.17.149.*
TrackBack来自《Travis Vytter》

Hello,admin!Your site is fantastic!
#ambien online 发表于2006-11-29 14:06:00  IP: 213.30.141.*
TrackBack来自《ambien online》

<a href="http://ebbs.ru/WY">ambien online</a>
#diazepam online 发表于2006-11-29 17:11:00  IP: 84.14.52.*
TrackBack来自《diazepam online》

<a href="http://ebbs.ru/He">diazepam online</a>
#college consolidation 发表于2006-11-29 20:08:00  IP: 200.159.30.*
TrackBack来自《college consolidation》

<a href="http://ebbs.ru/DM">college consolidation</a>
#Trevor Andrewe 发表于2006-12-02 04:52:00  IP: 203.185.129.*
TrackBack来自《Trevor Andrewe》

It's a very good site !! Very nice work, admin ;)
#Jefford Vichael 发表于2006-12-02 11:09:00  IP: 66.165.172.*
TrackBack来自《Jefford Vichael》

Excellent site. It was pleasant to me.
#Jefford Vichael 发表于2006-12-02 11:13:00  IP: 208.138.31.*
TrackBack来自《Jefford Vichael》

Excellent site. It was pleasant to me.
#Popen Bavid 发表于2006-12-02 14:06:00  IP: 202.83.206.*
TrackBack来自《Popen Bavid》

I love you so much! Great place to visit!
#Michael Katan 发表于2006-12-02 07:44:00  IP: 62.253.128.*
TrackBack来自《Michael Katan》

Yo have nice site, admin! keep up good work man.
#Davis Travis 发表于2006-12-02 08:15:00  IP: 72.32.59.*
TrackBack来自《Davis Travis》

Very good site, greate content.
#Andrew Wendya 发表于2006-12-02 22:22:00  IP: 61.238.244.*
TrackBack来自《Andrew Wendya》

Yo have nice site, admin! keep up good work man!
#k 发表于2004-12-29 12:32:00  IP: 220.194.16.*
Pear install phpDocumentor

这个命令不认啊!


提示信息
C:\>d:

D:\>cd D:\php-5.0.2-Win32

D:\php-5.0.2-Win32>Pear install phpDocumentor
'Pear' は、内部コマンドまたは外部コマンド、
操作可能なプログラムまたはバッチ ファイルとして認識されていません。

D:\php-5.0.2-Win32>cd pear

D:\php-5.0.2-Win32\PEAR>Pear install phpDocumentor
'Pear' は、内部コマンドまたは外部コマンド、
操作可能なプログラムまたはバッチ ファイルとして認識されていません。

D:\php-5.0.2-Win32\PEAR>cd D:\php-5.0.2-Win32

#maya 发表于2005-02-17 18:14:00  IP: 222.55.119.*
我靠,用日文版系统,牛人
#guard 发表于2005-02-28 10:14:00  IP: 211.72.233.*
аݧڥwebh͡ApGzLwؿ覡Ӳͤ
ڭnnLhMlؿɮשOH
#dos_fink 发表于2006-11-23 19:16:00  IP: 59.41.45.*
我靠,外星人的系统,牛人@_@
发表评论  


当前用户设置只有注册用户才能发表评论。如果你没有登录,请点击登录
Csdn Blog version 3.1a
Copyright © Silentangel