require doc

This commit is contained in:
dongwei 2019-01-14 15:30:04 +08:00
parent 5ab20df487
commit e153627a67
3 changed files with 60 additions and 16 deletions

View File

@ -12,5 +12,8 @@
"psr-4": { "psr-4": {
"JsonRpc\\": "src/" "JsonRpc\\": "src/"
} }
},
"require-dev": {
"itxq/api-doc-php": "^1.1"
} }
} }

47
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "20228fdc76a78774b09e7d2ba713c22a", "content-hash": "2bc6549f9c92876a91cb2530fc974c23",
"packages": [ "packages": [
{ {
"name": "doctrine/inflector", "name": "doctrine/inflector",
@ -1598,7 +1598,50 @@
"time": "2018-12-06T10:45:32+00:00" "time": "2018-12-06T10:45:32+00:00"
} }
], ],
"packages-dev": [], "packages-dev": [
{
"name": "itxq/api-doc-php",
"version": "v1.1.1",
"source": {
"type": "git",
"url": "https://github.com/itxq/api-doc-php.git",
"reference": "79ac71cf09da49491cfb92722d6f6e13ad8f6482"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/itxq/api-doc-php/zipball/79ac71cf09da49491cfb92722d6f6e13ad8f6482",
"reference": "79ac71cf09da49491cfb92722d6f6e13ad8f6482",
"shasum": "",
"mirrors": [
{
"url": "https://dl.laravel-china.org/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=5.6.0"
},
"type": "library",
"autoload": {
"psr-4": {
"itxq\\apidoc\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"Apache-2.0"
],
"authors": [
{
"name": "IT小强xqitw.cn",
"email": "360237521@qq.com"
}
],
"description": "api-doc-php",
"time": "2018-06-24T04:20:25+00:00"
}
],
"aliases": [], "aliases": [],
"minimum-stability": "stable", "minimum-stability": "stable",
"stability-flags": [], "stability-flags": [],

View File

@ -2,6 +2,8 @@
namespace JsonRpc\Server; namespace JsonRpc\Server;
use itxq\apidoc\BootstrapApiDoc;
class JsonRpcDoc class JsonRpcDoc
{ {
@ -18,10 +20,9 @@ class JsonRpcDoc
{ {
$methods = []; $methods = [];
foreach ($this->map as $key => $item) { foreach ($this->map as $key => $item) {
$methods[] = [ if (!in_array($item[0], $methods)) {
'method' => $key, $methods[] = $item[0];
'desc' => $this->desc($item[0], $item[1]), }
];
} }
return $methods; return $methods;
} }
@ -32,16 +33,13 @@ class JsonRpcDoc
/** /**
* @var $view Factory * @var $view Factory
*/ */
$view = view(); $config = [
'class' => $this->methods(),
dump($this->methods()); 'filter_method' => [],
exit; ];
$api = new BootstrapApiDoc($config);
$view->share('methods', $this->methods()); $doc = $api->getHtml();
exit($doc);
return $view->exists('doc') ?
$view->make('doc') :
$view->file(__DIR__ . '/../views/doc.blade.php');
} }
protected function desc($class, $method) protected function desc($class, $method)