Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions commands/ApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@ protected function findFiles($path, $except = [])
*/
protected function findRenderer($template)
{
if (class_exists($template)) {
return new $template();
}

$rendererClass = 'yii\\apidoc\\templates\\' . $template . '\\ApiRenderer';
if (!class_exists($rendererClass)) {
$this->stderr('Renderer not found.' . PHP_EOL);
Expand Down
70 changes: 70 additions & 0 deletions templates/json/ApiRenderer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/

namespace yii\apidoc\templates\json;

use yii\apidoc\models\Context;
use yii\apidoc\renderers\ApiRenderer as BaseApiRenderer;
use yii\base\ViewContextInterface;
use Yii;

/**
* The class for outputting documentation data structures as a JSON text.
*
* @author Tom Worster <[email protected]>
* @since 2.0.5
*/
class ApiRenderer extends BaseApiRenderer implements ViewContextInterface
{

/**
* Writes a given [[Context]] as JSON text to file 'types.json'.
*
* @param Context $context the api documentation context to render.
* @param $targetDir
*/
public function render($context, $targetDir)
{
$types = array_merge($context->classes, $context->interfaces, $context->traits);
file_put_contents($targetDir . '/types.json', json_encode($types, JSON_PRETTY_PRINT));
}

/**
* @inheritdoc
*/
public function generateApiUrl($typeName)
{
}

/**
* @inheritdoc
*/
protected function generateFileName($typeName)
{
}

/**
* @inheritdoc
*/
public function getViewPath()
{
}

/**
* @inheritdoc
*/
protected function generateLink($text, $href, $options = [])
{
}

/**
* @inheritdoc
*/
public function getSourceUrl($type, $line = null)
{
}
}