0
点赞
收藏
分享

微信扫一扫

PhpDocumentor手册-安装和标签使用


PhpDocumentor手册-安装和标签使用

1.安装

必须包含:php 5.3.3版本以上, intl for php 扩展 ,Graphviz

 

安装方式 使用 pear 命令

pear channel-discover pear.phpdoc.org

pear install phpdoc/phpDocumentor

 

2.DocBlock基本语法

 

DocBlock(文档块)
/**
 
* phpdocumentor 测试.
*
 
*/
 
DocBlock使用范围在以下结构元素中
l  namespace
l  require(_once)
l  include(_once)
l  class
l  interface
l  trait
l  function (including methods)
l  property
l  constant
l  variables, both local and global scope.
 
DocBlock例子
/**
 * 摘要:实现得到用户年龄的方法。
 
 *@param string $name 用户名称,需使用中文
 
 *@return 
 
*/
Function getage($name){
 ......
}

 

DocBlock包括三个部分

1.摘要

对整个功能的概要说明

 

2.说明

对功能或者标记扩展说明

算法说明

示例说明

版权许可说明...

 

对标记 的说明

 

3.标记

@api

@author

@category

@copyright

@deprecated

@example

@filesource

@global

@ignore

@internal

@license

@link

@method

@package

@param

@property

@property-read

@property-write

@return

@see

@since

@source

@subpackage

@throws

@todo

@uses & @used-by

@var

@version

 

3.标签的使用

Type:string , int, bool, floot , array, void 等等

详见 http://phpdoc.org/docs/latest/references/phpdoc/types.html

@api 标记该结构元素适合第三方的部件


@author 文档作者标记

使用语法

@author [name] [<email address>]

 

@package   封装包的名称 一组相关类、函数封装的包名称

使用语法

@package [level 1]\[level 2]\[etc.]

 

@copyright 版权信息

使用语法

@copyright [description]

 

@deprecated 弃用说明

使用语法

@deprecated [<version>] [<description>]

 

@example 示例代码的位置

使用语法

@example [location] [<start-line> [<number-of-lines>] ][<description>]

@example /www/web/default/test.php 1 3 代码在test.php文件中从第一行到第三行

 

@ignore 告诉phpdocumentor忽略处理的

使用语法

@ignore [<description>]

@ignore  phpdoc会忽略OS 常量的定义,不在文档中显示

 define("OS","Windows");

 

@license 许可说明

使用语法

@license [<url>] [name]

 

@link 链接外部更详细的信息

使用语法

@link [URI] [<description>]


@method 简单理解 表示 __call 魔法函数是 需要调用的方法

使用语法

@method [return type] [name]([[type] [parameter]<, ...>])[<description>]

@method void setInteger(integer $integer) 设定整数

 

@param 一个函数或者方法的参数

使用语法

@param [Type] [name] [<description>]

@param string $myArgument 我的一个字符串参数

 

@property 表示使用 __get()和__set()魔术方法 调用的属性

使用语法

@property [Type] [name] [<description>]

 

@return 方法或函数的返回值

使用语法

@return [Type] [<description>]

 

@see 查看相关联的结构元素或者网站

使用语法

@see [URI | FQSEN] [<description>]

@see \Phpdocumentor::$items   查看phpdocumentor类下的items属性

FQSEN解释:结构元素名称\My\Space\MyClass::myMethod()

 

@since 从哪个版本是开始使用

@since [version] [<description>]

 

@source 显示源代码

@source [<start-line> [<number-of-lines>] ][<description>]

 

@throws 抛出错误说明

@throws [Type] [<description>]

 

@todo 后续有待开发的描述

 

@uses & @used-by 查看参考相关结构元素

@uses [FQSEN] [<description>]

 

@var 变量或者属性

@var [“Type”] [$element_name][<description>]


使用phpdoc/phpDocumentor来生成api文档


谢谢关注websites博客!

举报

相关推荐

0 条评论