Compare commits
No commits in common. "6ba37efae51d5d57cf4b4c339b0e2e2d39bee09c" and "accce4537710f6212a332fe5ec78890514b20ee3" have entirely different histories.
6ba37efae5
...
accce45377
16
README.md
16
README.md
|
@ -1,22 +1,20 @@
|
|||
# Api-Doc-PHP
|
||||
|
||||
### 主要功能:
|
||||
|
||||
+ 根据接口注释自动生成接口文档
|
||||
|
||||
### 演示地址
|
||||
|
||||
[【Gitee Pages:】http://itxq.gitee.io/api-doc-php](http://itxq.gitee.io/api-doc-php)
|
||||
|
||||
### 开源地址:
|
||||
|
||||
[【GigHub:】https://github.com/itxq/api-doc-php](https://github.com/itxq/api-doc-php)
|
||||
|
||||
[【码云:】https://gitee.com/itxq/api-doc-php](https://github.com/itxq/api-doc-php)
|
||||
|
||||
|
||||
|
||||
### 主要功能:
|
||||
|
||||
+ 根据接口注释自动生成接口文档
|
||||
|
||||
### 扩展安装:
|
||||
|
||||
+ 方法一:composer命令 `composer require itxq/api-doc-php`
|
||||
+ 方法一:composer命令 `composer require itxq/wechat-sdk-php`
|
||||
|
||||
+ 方法二:直接下载压缩包,然后进入项目中执行 composer命令 `composer update` 来生成自动加载文件
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -26,11 +26,6 @@ class ApiDoc
|
|||
*/
|
||||
private $ApiTree = [];
|
||||
|
||||
/**
|
||||
* @var array - 结构化的数组
|
||||
*/
|
||||
private $DocTree = [];
|
||||
|
||||
/**
|
||||
* @var array - 要生成API的Class类名
|
||||
*/
|
||||
|
@ -128,51 +123,4 @@ class ApiDoc
|
|||
}
|
||||
return $comments;
|
||||
}
|
||||
|
||||
private function _getActionCommentTmp($class, $type = \ReflectionMethod::IS_PUBLIC) {
|
||||
try {
|
||||
$reflection = new \ReflectionClass($class);
|
||||
//只允许生成public方法
|
||||
$method = $reflection->getMethods($type);
|
||||
} catch (\Exception $exception) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$comments = [];
|
||||
foreach ($method as $key => $action) {
|
||||
try {
|
||||
$parse = new ParseComment();
|
||||
$actionComments = $parse->parseCommentToArray($action->getDocComment());
|
||||
if (count($actionComments) >= 1 && !in_array($action->name, $this->filterMethod)) {
|
||||
$comments[$actionComments['url']] = [
|
||||
'param' => $actionComments['param'],
|
||||
'code' => $actionComments['code'],
|
||||
'return' => $actionComments['return'],
|
||||
];
|
||||
}
|
||||
|
||||
} catch (\Exception $exception) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return $comments;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取API文档数据
|
||||
* @param int $type - 方法过滤,默认只获取 public类型 方法
|
||||
* ReflectionMethod::IS_STATIC
|
||||
* ReflectionMethod::IS_PUBLIC
|
||||
* ReflectionMethod::IS_PROTECTED
|
||||
* ReflectionMethod::IS_PRIVATE
|
||||
* ReflectionMethod::IS_ABSTRACT
|
||||
* ReflectionMethod::IS_FINAL
|
||||
* @return array
|
||||
*/
|
||||
public function getApiDocTmp($type = \ReflectionMethod::IS_PUBLIC) {
|
||||
foreach ($this->class as $classItem) {
|
||||
$this->DocTree = array_merge($this->DocTree,$this->_getActionCommentTmp($classItem, $type));
|
||||
}
|
||||
return $this->DocTree;
|
||||
}
|
||||
}
|
|
@ -52,7 +52,6 @@ class BootstrapApiDoc extends ApiDoc
|
|||
.action-item .action-title {text-indent: 0.6em;border-left: 3px solid #F0AD4E;font-size: 20px;margin: 8px 0;}
|
||||
.table-item {background-color:#FFFFFF;padding-top: 10px;margin-bottom:10px;border: solid 1px #ccc;border-radius: 5px;}
|
||||
.list-group-item-sub{padding: .5rem 1.25rem;}
|
||||
.copyright-content{margin: 10px 0;}
|
||||
</style>';
|
||||
|
||||
/**
|
||||
|
@ -136,8 +135,8 @@ class BootstrapApiDoc extends ApiDoc
|
|||
<div class="col-lg-12">{$this->_getDocList($data)}</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-lg-12 text-center copyright-content">
|
||||
Copyright 2016 - 2018 <a href="http://www.xqitw.cn">小强IT屋</a> 版权所有
|
||||
<div class="col-lg-12 text-center">
|
||||
版权的撒打算
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -234,6 +233,9 @@ EXT;
|
|||
$html = <<<EXT
|
||||
<div class="list-group-item list-group-item-action action-item col-md-12" id="{$className}_{$actionName}">
|
||||
<h4 class="action-title">API - {$actionItem['title']}</h4>
|
||||
<p>请求方式:
|
||||
<span class="btn btn-info btn-sm">{$actionItem['method']}</span>
|
||||
</p>
|
||||
<p>请求地址:<a href="{$actionItem['url']}">{$actionItem['url']}</a></p>
|
||||
{$this->_getParamData(Tools::getSubValue('param', $actionItem, []))}
|
||||
{$this->_getReturnData(Tools::getSubValue('return', $actionItem, []))}
|
||||
|
@ -303,9 +305,7 @@ EXT;
|
|||
}
|
||||
$html .= '</div></li>';
|
||||
}
|
||||
if (!isset($_GET['download']) || $_GET['download'] !== 'api_doc_php') {
|
||||
$html .= ' <li class="nav-item"><a class="nav-link" href="?download=api_doc_php">下载文档</a></li>';
|
||||
}
|
||||
$html .= '</ul>';
|
||||
return $html;
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ class ParseLine
|
|||
* @return array
|
||||
*/
|
||||
public function parseLineTitle($line) {
|
||||
return ['type' => isset($line[0]) ? $line[0] : '', 'content' => isset($line[1]) ? $line[1] : ''];
|
||||
return ['type' => $line[0], 'content' => $line[1]];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -35,12 +35,12 @@ class ParseLine
|
|||
*/
|
||||
public function parseLineParam($line) {
|
||||
return [
|
||||
'type' => isset($line[0]) ? $line[0] : '',
|
||||
'param_type' => isset($line[1]) ? $line[1] : '',
|
||||
'param_name' => isset($line[2]) ? $line[2] : '',
|
||||
'param_title' => isset($line[3]) ? $line[3] : '',
|
||||
'param_default' => isset($line[4]) ? $line[4] : '',
|
||||
'param_require' => isset($line[5]) ? $line[5] : '',
|
||||
'type' => $line[0],
|
||||
'param_type' => $line[1],
|
||||
'param_name' => $line[2],
|
||||
'param_title' => $line[3],
|
||||
'param_default' => $line[4],
|
||||
'param_require' => $line[5],
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -51,8 +51,8 @@ class ParseLine
|
|||
*/
|
||||
public function parseLineCode($line) {
|
||||
return [
|
||||
'type' => isset($line[0]) ? $line[0] : '',
|
||||
'code' => isset($line[1]) ? $line[1] : '',
|
||||
'type' => $line[0],
|
||||
'code' => $line[1],
|
||||
'content' => isset($line[2]) ? $line[2] : '',
|
||||
];
|
||||
}
|
||||
|
@ -64,9 +64,9 @@ class ParseLine
|
|||
*/
|
||||
public function parseLineReturn($line) {
|
||||
return [
|
||||
'type' => isset($line[0]) ? $line[0] : '',
|
||||
'return_type' => isset($line[1]) ? $line[1] : '',
|
||||
'return_name' => isset($line[2]) ? $line[2] : '',
|
||||
'type' => $line[0],
|
||||
'return_type' => $line[1],
|
||||
'return_name' => $line[2],
|
||||
'return_title' => isset($line[3]) ? $line[3] : '',
|
||||
];
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user