BaseRenderer.php 1.83 KB
Newer Older
1 2
<?php
/**
3 4 5
 * @link http://www.yiiframework.com/
 * @copyright Copyright (c) 2008 Yii Software LLC
 * @license http://www.yiiframework.com/license/
6 7
 */

8
namespace yii\apidoc\templates;
9 10

use Yii;
11 12 13 14 15 16 17 18
use yii\apidoc\models\ClassDoc;
use yii\apidoc\models\ConstDoc;
use yii\apidoc\models\Context;
use yii\apidoc\models\EventDoc;
use yii\apidoc\models\InterfaceDoc;
use yii\apidoc\models\MethodDoc;
use yii\apidoc\models\PropertyDoc;
use yii\apidoc\models\TraitDoc;
19 20 21
use yii\base\Component;
use yii\console\Controller;

22 23 24 25 26 27
/**
 * Base class for all API documentation renderers
 *
 * @author Carsten Brandt <mail@cebe.cc>
 * @since 2.0
 */
28 29
abstract class BaseRenderer extends Component
{
30 31 32 33
	/**
	 * @var Context the [[Context]] currently being rendered.
	 */
	public $context;
34 35 36
	/**
	 * @var array files for guide pages
	 */
37
	public $markDownFiles = [];
38

39
	/**
40 41 42 43
	 * Renders a given [[Context]].
	 *
	 * @param Context $context the api documentation context to render.
	 * @param Controller $controller the apidoc controller instance. Can be used to control output.
44
	 */
45 46 47 48 49 50 51 52 53
	public abstract function renderApi($context, $controller);

	/**
	 * Renders a given [[Context]].
	 *
	 * @param array $files list of markdown files to render
	 * @param Context $context the api documentation context to render.
	 * @param Controller $controller the apidoc controller instance. Can be used to control output.
	 */
54
	public abstract function renderMarkdownFiles($controller);
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70

	/**
	 * creates a link to a type (class, interface or trait)
	 * @param ClassDoc|InterfaceDoc|TraitDoc $types
	 * @param string $title
	 * @return string
	 */
	public abstract function typeLink($types, $title = null);

	/**
	 * creates a link to a subject
	 * @param PropertyDoc|MethodDoc|ConstDoc|EventDoc $subject
	 * @param string $title
	 * @return string
	 */
	public abstract function subjectLink($subject, $title = null);
71
}