Skip to content

Commit

Permalink
screenshot demo update
Browse files Browse the repository at this point in the history
  • Loading branch information
chatfeed committed Jan 5, 2018
1 parent 6524e93 commit 122f571
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 1 deletion.
40 changes: 40 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,41 @@
# yii2-doc
======================
auto generate api document by using comment for yii2.

Installation
======================

```
composer require chatfeed/yii2-doc "*"
```

Configure
======================

```php
'module'=>[
'doc' => [
'class' => 'cfd\doc\Module',
'modelDescriptions'=>require __DIR__.'/model_description.php',
'modelsMap'=>[
'\common\base_models\kds\\',
]
]
]
```

Define Customer Model
======================
```php
return [
'demo'=>[
['object','demo','模型'],
['integer','id','ID'],
['string','name','名称'],
['string','desc','描述'],
['integer','created_at','创建时间'],
['integer','updated_at','更新时间'],
]
];
```
Thanks [yii2-fast-api](https://github.com/deepziyu/yii2-fast-api)
3 changes: 2 additions & 1 deletion components/DocObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ public function getObject($name,$attributes=[])
}elseif(isset($labels[$a])){
$label = $labels[$a];
}else{
var_dump("{$classname} {$a} label 不存在");exit;
throw new UserException("{$classname} {$a} label 不存在");
}
$ret[] = [
Expand All @@ -93,7 +94,7 @@ public function getObject($name,$attributes=[])
$label
];
}else{
var_dump($labels,$matches);exit;
var_dump("{$classname}{$a} 文档注释不存在");exit;
throw new UserException("{$classname}{$a} 文档注释不存在");
}
}
Expand Down
5 changes: 5 additions & 0 deletions controllers/DemoController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
* Time: 下午2:19
*/

/**
* @desc 示例模块
* @package cfd\doc\controllers
*/
class DemoController extends \yii\web\Controller{

/**
Expand All @@ -20,6 +24,7 @@ class DemoController extends \yii\web\Controller{
* @doc-return object<demo@id,name> demo2 自定义模型可选字段
* @doc-return object<teacher> tec 自有数据模型
* @doc-return object<teacher@cardId,is_checked> tec 自有数据模型选用字段
* @doc-return array<teacher@cardId> tlist 对象列表
*/
public function actionGet(){

Expand Down
Binary file added screenshot.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 122f571

Please sign in to comment.