-
-
Notifications
You must be signed in to change notification settings - Fork 121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add new template for running yii2-apidoc on a user-submitted project #151
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
@@ -0,0 +1,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); | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Silencing errors isn't good. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suppose I could throw an exception here. Would that be preferred? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just for the record, Bootstrap template silences errors, too:
|
||||
$indexFileContent = $this->renderWithLayout($this->indexView, [ | ||||
'docContext' => $context, | ||||
'types' => $appTypes ?: null, | ||||
'readme' => $readme ?: null, | ||||
]); | ||||
|
||||
file_put_contents($targetDir . '/index.html', $indexFileContent); | ||||
} | ||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?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 GuideRenderer extends \yii\apidoc\templates\bootstrap\GuideRenderer | ||
{ | ||
use \yii\apidoc\templates\bootstrap\RendererTrait; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why URL instead of local file path?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That URL was hard-coded in the bootstrap template which I copied. For it to work without changing the command line params, it has to match the value that was in the previous template.