diff --git a/commands/ApiController.php b/commands/ApiController.php index 2696e842..9da2946e 100644 --- a/commands/ApiController.php +++ b/commands/ApiController.php @@ -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); diff --git a/templates/json/ApiRenderer.php b/templates/json/ApiRenderer.php new file mode 100644 index 00000000..fb66da43 --- /dev/null +++ b/templates/json/ApiRenderer.php @@ -0,0 +1,70 @@ + + * @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) + { + } +}