-
-
Notifications
You must be signed in to change notification settings - Fork 121
/
Copy pathApiRenderer.php
53 lines (43 loc) · 1.37 KB
/
ApiRenderer.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace yii\apidoc\templates\project;
use Yii;
use yii\apidoc\helpers\ApiIndexer;
use yii\helpers\Console;
use yii\helpers\FileHelper;
/**
*
* @author Carsten Brandt <[email protected]>
* @since 2.0
*/
class ApiRenderer extends \yii\apidoc\templates\bootstrap\ApiRenderer
{
use \yii\apidoc\templates\bootstrap\RendererTrait;
public $layout = '@yii/apidoc/templates/bootstrap/layouts/api.php';
public $indexView = '@yii/apidoc/templates/bootstrap/views/index.php';
/**
* @inheritdoc
*/
public function render($context, $targetDir)
{
// render view files
parent::render($context, $targetDir);
if ($this->controller !== null) {
$this->controller->stdout('generating extension index files...');
}
$types = array_merge($context->classes, $context->interfaces, $context->traits);
$appTypes = $this->filterTypes($types, 'app');
// It's a hack, but we'll go with it for now.
$readme = @file_get_contents($this->readmeUrl);
$indexFileContent = $this->renderWithLayout($this->indexView, [
'docContext' => $context,
'types' => $appTypes ?: null,
'readme' => $readme ?: null,
]);
file_put_contents($targetDir . '/index.html', $indexFileContent);
}
}