什么是phpDocumentor第1/2页
1. 什么是phpDocumentor ?
PHPDocumentor是一个用PHP写的工具,对于有规范注释的php程序,它能够快速生成具有相互参照,索引等功能的API文档。老的版本是 phpdoc,从1.3.0开始,更名为phpDocumentor,新的版本加上了对php5语法的支持,同时,可以通过在客户端浏览器上操作生成文档,文档可以转换为PDF,HTML,CHM几种形式,非常的方便。
PHPDocumentor工作时,会扫描指定目录下面的php源代码,扫描其中的关键字,截取需要分析的注释,然后分析注释中的专用的tag,生成 xml文件,接着根据已经分析完的类和模块的信息,建立相应的索引,生成xml文件,对于生成的xml文件,使用定制的模板输出为指定格式的文件。
2. 安装phpDocumentor
和其他pear下的模块一样,phpDocumentor的安装也分为自动安装和手动安装两种方式,两种方式都非常方便:
a. 通过pear 自动安装
在命令行下输入
pear install PhpDocumentor
b. 手动安装
在http://manual.phpdoc.org/下载最新版本的PhpDocumentor(现在是1.4.0),把内容解压即可。
3.怎样使用PhpDocumentor生成文档
命令行方式:
在phpDocumentor所在目录下,输入
Php –h
会得到一个详细的参数表,其中几个重要的参数如下:
-f 要进行分析的文件名,多个文件用逗号隔开
-d 要分析的目录,多个目录用逗号分割
-t 生成的文档的存放路径
-o 输出的文档格式,结构为输出格式:转换器名:模板目录。
例如:phpdoc -o HTML:frames:earthli -f test.php -t docs
Web界面生成
在新的phpdoc中,除了在命令行下生成文档外,还可以在客户端浏览器上操作生成文档,具体方法是先把PhpDocumentor的内容放在apache目录下使得通过浏览器可以访问到,访问后显示如下的界面:
点击files按钮,选择要处理的php文件或文件夹,还可以通过该指定该界面下的Files to ignore来忽略对某些文件的处理。
然后点击output按钮来选择生成文档的存放路径和格式.
最后点击create,phpdocumentor就会自动开始生成文档了,最下方会显示生成的进度及状态,如果成功,会显示
Total Documentation Time: 1 seconds
done
Operation Completed!!
然后,我们就可以通过查看生成的文档了,如果是pdf格式的,名字默认为documentation.pdf。
4.给php代码添加规范的注释
PHPDocument是从你的源代码的注释中生成文档,因此在给你的程序做注释的过程,也就是你编制文档的过程。
从这一点上讲,PHPdoc促使你要养成良好的编程习惯,尽量使用规范,清晰文字为你的程序做注释,同时多多少少也避免了事后编制文档和文档的更新不同步的一些问题。
在phpdocumentor中,注释分为文档性注释和非文档性注释。
所谓文档性注释,是那些放在特定关键字前面的多行注释,特定关键字是指能够被phpdoc分析的关键字,例如class,var等,具体的可参加附录1.
那些没有在关键字前面或者不规范的注释就称作非文档性注释,这些注释将不会被phpdoc所分析,也不会出现在你产生的api文当中。
3.2如何书写文档性注释:
所有的文档性注释都是由/**开始的一个多行注释,在phpDocumentor里称为DocBlock, DocBlock是指软件开发人员编写的关于某个关键字的帮助信息,使得其他人能够通过它知道这个关键字的具体用途,如何使用。 PhpDocumentor规定一个DocBlock包含如下信息:
1. 功能简述区
2. 详细说明区
3. 标记tag
文档性注释的第一行是功能描述区,正文一般是简明扼要地说明这个类,方法或者函数的功能,功能简述的正文在生成的文档中将显示在索引区。功能描述区的内容可以通过一个空行或者 . 来结束
在功能描述区后是一个空行,接着是详细说明区,. 这部分主要是详细说明你的API的功能,用途,如果可能,也可以有用法举例等等。在这部分,你应该着重阐明你的API函数或者方法的通常的用途,用法,并且指明是否是跨平台的(如果涉及到),对于和平台相关的信息,你要和那些通用的信息区别对待,通常的做法是另起一行,然后写出在某个特定平台上的注意事项或者是特别的信息,这些信息应该足够,以便你的读者能够编写相应的测试信息,比如边界条件,参数范围,断点等等。
之后同样是一个空白行,然后是文档的标记tag,指明一些技术上的信息,主要是最主要的是调用参数类型,返回值极其类型,继承关系,相关方法/函数等等。
关于文档标记,详细的请参考第四节:文档标记。
文档注释中还可以使用例如 这样的标签,详细介绍请参考附录二。 <br>下面是一个文档注释的例子 <br><br>/** <br>* 函数add,实现两个数的加法 <br>* <br>* 一个简单的加法计算,函数接受两个数a、b,返回他们的和c <br>* <br>* @param int 加数 <br>* @param int 被加数 <br>* @return integer <br>*/ <br>function Add($a, $b) <br>{ <br>return $a+$b; <br>} <br>生成文档如下: <br>Add <br>integer Add( int $a, int $b) <br>[line 45] <br>函数add,实现两个数的加法 <br>Constants 一个简单的加法计算,函数接受两个数a、b,返回他们的和c <br>Parameters <br>• int $a - 加数 <br>• int $b - 被加数 <br><br>5.文档标记: <br>文档标记的使用范围是指该标记可以用来修饰的关键字,或其他文档标记。 <br>所有的文档标记都是在每一行的 * 后面以@开头。如果在一段话的中间出来@的标记,这个标记将会被当做普通内容而被忽略掉。 <br>@access <br>使用范围:class,function,var,define,module <br>该标记用于指明关键字的存取权限:private、public或proteced <br>@author <br>指明作者 <br>@copyright <br>使用范围:class,function,var,define,module,use <br>指明版权信息 <br>@deprecated <br>使用范围:class,function,var,define,module,constent,global,include <br>指明不用或者废弃的关键字 <br>@example <br>该标记用于解析一段文件内容,并将他们高亮显示。Phpdoc会试图从该标记给的文件路径中读取文件内容 <br>@const <br>使用范围:define <br>用来指明php中define的常量 <br>@final <br>使用范围:class,function,var <br>指明关键字是一个最终的类、方法、属性,禁止派生、修改。 <br><br>@filesource <br>和example类似,只不过该标记将直接读取当前解析的php文件的内容并显示。 <br>@global <br>指明在此函数中引用的全局变量 <br>@ingore <br>用于在文档中忽略指定的关键字 <br>@license <br>相当于html标签中的<a>,首先是URL,接着是要显示的内容 <br>例如</a><a href="%E2%80%9Dhttp://www.baidu.com%E2%80%9D">百度</a> <br>可以写作 @license http://www.baidu.com 百度 <br>@link <br>类似于license <br>但还可以通过link指到文档中的任何一个关键字 <br>@name <br>为关键字指定一个别名。 <br>@package <br>使用范围:页面级别的-> define,function,include <br>类级别的->class,var,methods <br>用于逻辑上将一个或几个关键字分到一组。 <br>@abstrcut <br>说明当前类是一个抽象类 <br><br>@param <br>指明一个函数的参数 <br>@return <br>指明一个方法或函数的返回指 <br>@static <br>指明关建字是静态的。 <br>@var <br>指明变量类型 <br>@version <br>指明版本信息 <br>@todo <br>指明应该改进或没有实现的地方 <br>@throws <br>指明此函数可能抛出的错误异常,极其发生的情况 <br>上面提到过,普通的文档标记标记必须在每行的开头以@标记,除此之外,还有一种标记叫做inline tag,用{@}表示,具体包括以下几种: <br>{@link} <br>用法同@link <br>{@source} <br>显示一段函数或方法的内容 <br><br>6.一些注释规范 <br>a.注释必须是 <br>/** <br>* XXXXXXX <br>*/ <br>的形式 <br>b.对于引用了全局变量的函数,必须使用glboal标记。 <br>c.对于变量,必须用var标记其类型(int,string,bool...) <br>d.函数必须通过param和return标记指明其参数和返回值 <br>e.对于出现两次或两次以上的关键字,要通过ingore忽略掉多余的,只保留一个即可 <br>f.调用了其他函数或类的地方,要使用link或其他标记链接到相应的部分,便于文档的阅读。 <br>g.必要的地方使用非文档性注释,提高代码易读性。 <br>h.描述性内容尽量简明扼要,尽可能使用短语而非句子。 <br>i.全局变量,静态变量和常量必须用相应标记说明 <br>

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











How to set up keyboard startup on Gigabyte's motherboard. First, if it needs to support keyboard startup, it must be a PS2 keyboard! ! The setting steps are as follows: Step 1: Press Del or F2 to enter the BIOS after booting, and go to the Advanced (Advanced) mode of the BIOS. Ordinary motherboards enter the EZ (Easy) mode of the motherboard by default. You need to press F7 to switch to the Advanced mode. ROG series motherboards enter the BIOS by default. Advanced mode (we use Simplified Chinese to demonstrate) Step 2: Select to - [Advanced] - [Advanced Power Management (APM)] Step 3: Find the option [Wake up by PS2 keyboard] Step 4: This option The default is Disabled. After pulling down, you can see three different setting options, namely press [space bar] to turn on the computer, press group

What graphics card is good for Core i73770? RTX3070 is a very powerful graphics card with excellent performance and advanced technology. Whether you're playing games, rendering graphics, or performing machine learning, the RTX3070 can handle it with ease. It uses NVIDIA's Ampere architecture, has 5888 CUDA cores and 8GB of GDDR6 memory, which can provide a smooth gaming experience and high-quality graphics effects. RTX3070 also supports ray tracing technology, which can present realistic light and shadow effects. All in all, the RTX3070 is a powerful and advanced graphics card suitable for those who pursue high performance and high quality. RTX3070 is an NVIDIA series graphics card. Powered by 2nd generation NVID

Which tablet is suitable for musicians? The 12.9-inch speaker in Huawei’s iPad is a very good product. It comes with four speakers and the sound is excellent. Moreover, it belongs to the pro series, which is slightly better than other styles. Overall, ipad pro is a very good product. The speaker of this mini4 mobile phone is small and the effect is average. It cannot be used to play music externally, you still need to rely on headphones to enjoy music. Headphones with good sound quality will have a slightly better effect, but cheap headphones worth thirty or forty yuan cannot meet the requirements. What tablet should I use for electronic piano music? If you want to buy an iPad larger than 10 inches, I recommend using two applications, namely Henle and Piascore. Provided by Henle

What driver is good to install on rx5808g? 20.5.1 and 20.4.2WHQL refer to the version number of the software or driver. These version numbers are typically used to identify updates or fixes to software or drivers. In the computer world, WHQL stands for Windows Hardware Quality Labs, which is an institution used by Microsoft to test and verify the compliance and stability of hardware and drivers. Therefore, 20.5.1 and 20.4.2WHQL indicate that these software or drivers have passed Microsoft's testing and verification and can be safely used in the Windows operating system. AMDrx580 graphics card relatively stable drivers 20.5.1 and 20.4.2WHQL refers to the version number of the software or driver. These version numbers are passed

What games can be played with i34150 with 1G independent graphics? Can it play small games such as LoL? GTX750 and GTX750TI are very suitable graphics card choices. If you just play some small games or not play games, it is recommended to use the i34150 integrated graphics card. Generally speaking, the price difference between graphics cards and processors is not very big, so it is important to choose a reasonable combination. If you need 2G of video memory, it is recommended to choose GTX750TI; if you only need 1G of video memory, just choose GTX750. GTX750TI can be seen as an enhanced version of GTX750, with overclocking capabilities. Which graphics card can be paired with i34150 depends on your needs. If you plan to play stand-alone games, it is recommended that you consider changing the graphics card. you can choose

In the process of using the Windows 10 operating system developed by Microsoft, many users are curious and confused about the new technology called Cortana. Cortana's official name in the Chinese context is "Cortana", which is actually a built-in function of the Windows 10 system. Cortana, an artificial intelligence (AIassistant) service program. Frequently asked questions and solutions. How to open Cortana and not respond. Solution steps. Chinese solution is not supported. How to put the search box into Cortana. What software is Cortana? Answer: "Cortana" It is a cloud platform personal intelligent assistant carefully built by Microsoft. It has two usage modes: login and non-login. When you are logged in

The C library memory allocation function void*calloc(size_tnitems,size_tsize) allocates the requested memory and returns a pointer to it. The difference between malloc and calloc is that malloc does not set the memory to zero, while calloc sets the allocated memory to zero. Memory Allocation Function Memory can be allocated in two ways as mentioned below - Once memory is allocated at compile time, it cannot be changed during execution. There will be problems of insufficient or wasted memory. The solution is to create memory dynamically, that is, create memory according to the user's requirements during the execution of the program. The standard library functions for dynamic memory management are as follows: -malloc()calloc()realloc()free

Which version of the graphics card driver is best to use? 1. There is no absolute best version. It is most important to choose the version that suits your computer; 2. Because the applicability and stability of the graphics card driver version are related to the computer hardware environment and system configuration; 3. You can check the detailed information of the computer and graphics card on the official website, select the appropriate driver version based on the information, or refer to the reviews of other users. It is recommended to back up the system before installing the driver to avoid unexpected situations. Graphics card driver version 472.19 series is an excellent choice. Currently, the driver compatibility of version 472 is the best. Installing version 472 of the driver can also maximize the performance of the graphics card. The NVIDIA graphics card driver Win7 installation version, numbered 2, 472.19, is a product with remarkable quality.
