Browse Source

renamed item -> type

tags/2.0.0-beta
Carsten Brandt 11 years ago
parent
commit
8495be76c0
  1. 26
      extensions/yii/apidoc/components/OfflineRenderer.php
  2. 61
      extensions/yii/apidoc/views/class.php
  3. 49
      extensions/yii/apidoc/views/classSummary.php
  4. 8
      extensions/yii/apidoc/views/constSummary.php
  5. 8
      extensions/yii/apidoc/views/eventSummary.php
  6. 6
      extensions/yii/apidoc/views/index.php
  7. 8
      extensions/yii/apidoc/views/methodSummary.php
  8. 8
      extensions/yii/apidoc/views/propertySummary.php
  9. 98
      extensions/yii/apidoc/views/type.php

26
extensions/yii/apidoc/components/OfflineRenderer.php

@ -28,7 +28,7 @@ class OfflineRenderer extends BaseRenderer implements ViewContextInterface
public $targetDir;
public $layout = '@yii/apidoc/views/layouts/offline.php';
public $itemView = '@yii/apidoc/views/class.php';
public $typeView = '@yii/apidoc/views/type.php';
public $indexView = '@yii/apidoc/views/index.php';
public $pageTitle = 'Yii Framework 2.0 API Documentation';
@ -50,24 +50,24 @@ class OfflineRenderer extends BaseRenderer implements ViewContextInterface
mkdir($dir);
}
$items = array_merge($context->classes, $context->interfaces, $context->traits);
$itemCount = count($items) + 1;
Console::startProgress(0, $itemCount, 'Rendering files: ', false);
$types = array_merge($context->classes, $context->interfaces, $context->traits);
$typeCount = count($types) + 1;
Console::startProgress(0, $typeCount, 'Rendering files: ', false);
$done = 0;
foreach($items as $item) {
$fileContent = $this->renderWithLayout($this->itemView, [
'item' => $item,
foreach($types as $type) {
$fileContent = $this->renderWithLayout($this->typeView, [
'type' => $type,
'docContext' => $context,
]);
file_put_contents($dir . '/' . $this->generateFileName($item->name), $fileContent);
Console::updateProgress(++$done, $itemCount);
file_put_contents($dir . '/' . $this->generateFileName($type->name), $fileContent);
Console::updateProgress(++$done, $typeCount);
}
$indexFileContent = $this->renderWithLayout($this->indexView, [
'docContext' => $context,
'items' => $items,
'types' => $types,
]);
file_put_contents($dir . '/index.html', $indexFileContent);
Console::updateProgress(++$done, $itemCount);
Console::updateProgress(++$done, $typeCount);
Console::endProgress(true);
$controller->stdout('done.' . PHP_EOL, Console::FG_GREEN);
@ -209,9 +209,9 @@ class OfflineRenderer extends BaseRenderer implements ViewContextInterface
}
public function generateFileName($itemName)
public function generateFileName($typeName)
{
return strtolower(str_replace('\\', '_', $itemName)) . '.html';
return strtolower(str_replace('\\', '_', $typeName)) . '.html';
}
/**

61
extensions/yii/apidoc/views/class.php

@ -1,61 +0,0 @@
<?php
use yii\apidoc\models\ClassDoc;
use yii\apidoc\models\InterfaceDoc;
use yii\apidoc\models\TraitDoc;
/**
* @var ClassDoc|InterfaceDoc|TraitDoc $item
* @var yii\web\View $this
*/
?>
<h1><?php
if ($item instanceof InterfaceDoc) {
echo 'Interface ';
} elseif ($item instanceof TraitDoc) {
echo 'Trait ';
} else {
if ($item->isFinal) {
echo 'Final ';
}
if ($item->isAbstract) {
echo 'Abstract ';
}
echo 'Class ';
}
echo $item->name;
?></h1>
<div id="nav">
<a href="index.html">All Classes</a>
<?php if(!($item instanceof InterfaceDoc) && !empty($item->properties)): ?>
| <a href="#properties">Properties</a>
<?php endif; ?>
<?php if(!empty($item->methods)): ?>
| <a href="#methods">Methods</a>
<?php endif; ?>
<?php if($item instanceof ClassDoc && !empty($item->events)): ?>
| <a href="#events">Events</a>
<?php endif; ?>
<?php if($item instanceof ClassDoc && !empty($item->constants)): ?>
| <a href="#constants">Constants</a>
<?php endif; ?>
</div>
<?= $this->render('classSummary', ['item' => $item]) ?>
<a name="properties"></a>
<?= $this->render('propertySummary', ['item' => $item,'protected' => false]) ?>
<?= $this->render('propertySummary', ['item' => $item,'protected' => true]) ?>
<a name="methods"></a>
<?= $this->render('methodSummary', ['item' => $item, 'protected' => false]) ?>
<?= $this->render('methodSummary', ['item' => $item, 'protected' => true]) ?>
<a name="events"></a>
<?= $this->render('eventSummary', ['item' => $item]) ?>
<a name="constants"></a>
<?= $this->render('constSummary', ['item' => $item]) ?>
<?php //$this->renderPartial('propertyDetails',array('class'=>$item)); ?>
<?php //$this->renderPartial('methodDetails',array('class'=>$item)); ?>

49
extensions/yii/apidoc/views/classSummary.php

@ -1,49 +0,0 @@
<?php
use yii\apidoc\components\OfflineRenderer;
use yii\apidoc\models\ClassDoc;
use yii\apidoc\models\InterfaceDoc;
use yii\apidoc\models\TraitDoc;
/**
* @var ClassDoc|InterfaceDoc|TraitDoc $item
* @var yii\web\View $this
* @var OfflineRenderer $renderer
*/
$renderer = $this->context;
?><table class="summaryTable docClass">
<colgroup>
<col class="col-name" />
<col class="col-value" />
</colgroup>
<?php if ($item instanceof ClassDoc): ?>
<tr><th>Inheritance</th><td><?= $renderer->renderInheritance($item) ?></td></tr>
<?php endif; ?>
<?php if ($item instanceof ClassDoc && !empty($item->interfaces)): ?>
<tr><th>Implements</th><td><?= $renderer->renderInterfaces($item->interfaces) ?></td></tr>
<?php endif; ?>
<?php if(!($item instanceof InterfaceDoc) && !empty($item->traits)): ?>
<tr><th>Uses Traits</th><td><?= $renderer->renderTraits($item->traits) ?></td></tr>
<?php endif; ?>
<?php if($item instanceof ClassDoc && !empty($item->subclasses)): ?>
<tr><th>Subclasses</th><td><?= $renderer->renderClasses($item->subclasses) ?></td></tr>
<?php endif; ?>
<?php if ($item instanceof InterfaceDoc && !empty($item->implementedBy)): ?>
<tr><th>Implemented by</th><td><?= $renderer->renderClasses($item->implementedBy) ?></td></tr>
<?php endif; ?>
<?php if ($item instanceof TraitDoc && !empty($item->usedBy)): ?>
<tr><th>Implemented by</th><td><?= $renderer->renderClasses($item->usedBy) ?></td></tr>
<?php endif; ?>
<?php if(!empty($item->since)): ?>
<tr><th>Available since version</th><td><?= $item->since ?></td></tr>
<?php endif; ?>
<tr>
<th>Source Code</th>
<td><?php // TODO echo $this->renderSourceLink($item->sourcePath) ?></td>
</tr>
</table>
<div id="classDescription">
<strong><?= $item->shortDescription ?></strong>
<p><?= nl2br($item->description) ?></p>
</div>

8
extensions/yii/apidoc/views/constSummary.php

@ -2,11 +2,11 @@
use yii\apidoc\models\ClassDoc;
/**
* @var ClassDoc $item
* @var ClassDoc $type
* @var yii\web\View $this
*/
if (empty($item->constants)) {
if (empty($type->constants)) {
return;
} ?>
<div class="summary docConst">
@ -23,8 +23,8 @@ if (empty($item->constants)) {
<tr>
<th>Constant</th><th>Description</th><th>Defined By</th>
</tr>
<?php foreach($item->constants as $constant): ?>
<tr<?= $constant->definedBy != $item->name ? ' class="inherited"' : '' ?> id="<?= $constant->name ?>">
<?php foreach($type->constants as $constant): ?>
<tr<?= $constant->definedBy != $type->name ? ' class="inherited"' : '' ?> id="<?= $constant->name ?>">
<td><?= $this->context->subjectLink($constant) ?></td>
<td><?= $constant->shortDescription ?></td>
<td><?= $this->context->typeLink($constant->definedBy) ?></td>

8
extensions/yii/apidoc/views/eventSummary.php

@ -2,11 +2,11 @@
use yii\apidoc\models\ClassDoc;
/**
* @var ClassDoc $item
* @var ClassDoc $type
* @var yii\web\View $this
*/
if (empty($item->events)) {
if (empty($type->events)) {
return;
} ?>
<div class="summary docEvent">
@ -23,8 +23,8 @@ if (empty($item->events)) {
<tr>
<th>Event</th><th>Description</th><th>Defined By</th>
</tr>
<?php foreach($item->events as $event): ?>
<tr<?= $event->definedBy != $item->name ? ' class="inherited"' : '' ?> id="<?= $event->name ?>">
<?php foreach($type->events as $event): ?>
<tr<?= $event->definedBy != $type->name ? ' class="inherited"' : '' ?> id="<?= $event->name ?>">
<td><?= $this->context->subjectLink($event) ?></td>
<td><?= $event->shortDescription ?></td>
<td><?= $this->context->typeLink($event->definedBy) ?></td>

6
extensions/yii/apidoc/views/index.php

@ -4,7 +4,7 @@ use yii\apidoc\models\ClassDoc;
use yii\apidoc\models\InterfaceDoc;
use yii\apidoc\models\TraitDoc;
/**
* @var ClassDoc[]|InterfaceDoc[]|TraitDoc[] $items
* @var ClassDoc[]|InterfaceDoc[]|TraitDoc[] $types
* @var yii\web\View $this
*/
@ -20,8 +20,8 @@ use yii\apidoc\models\TraitDoc;
<th>Class</th><th>Description</th>
</tr>
<?php
ksort($items);
foreach($items as $i=>$class): ?>
ksort($types);
foreach($types as $i=>$class): ?>
<tr>
<td><?php echo $this->context->typeLink($class, $class->name); ?></td>
<td><?php echo $class->shortDescription; ?></td>

8
extensions/yii/apidoc/views/methodSummary.php

@ -4,12 +4,12 @@ use yii\apidoc\models\ClassDoc;
use yii\apidoc\models\InterfaceDoc;
use yii\apidoc\models\TraitDoc;
/**
* @var ClassDoc|InterfaceDoc|TraitDoc $item
* @var ClassDoc|InterfaceDoc|TraitDoc $type
* @var boolean $protected
* @var yii\web\View $this
*/
if ($protected && count($item->getProtectedMethods()) == 0 || !$protected && count($item->getPublicMethods()) == 0) {
if ($protected && count($type->getProtectedMethods()) == 0 || !$protected && count($type->getPublicMethods()) == 0) {
return;
} ?>
@ -27,9 +27,9 @@ if ($protected && count($item->getProtectedMethods()) == 0 || !$protected && cou
<tr>
<th>Method</th><th>Description</th><th>Defined By</th>
</tr>
<?php foreach($item->methods as $method): ?>
<?php foreach($type->methods as $method): ?>
<?php if($protected && $method->visibility == 'protected' || !$protected && $method->visibility != 'protected'): ?>
<tr<?= $method->definedBy != $item->name ? ' class="inherited"' : '' ?> id="<?= $method->name ?>">
<tr<?= $method->definedBy != $type->name ? ' class="inherited"' : '' ?> id="<?= $method->name ?>">
<td><?= $this->context->subjectLink($method, $method->name.'()') ?></td>
<td><?= $method->shortDescription ?></td>
<td><?= $this->context->typeLink($method->definedBy) ?></td>

8
extensions/yii/apidoc/views/propertySummary.php

@ -4,12 +4,12 @@ use yii\apidoc\models\ClassDoc;
use yii\apidoc\models\InterfaceDoc;
use yii\apidoc\models\TraitDoc;
/**
* @var ClassDoc|InterfaceDoc|TraitDoc $item
* @var ClassDoc|InterfaceDoc|TraitDoc $type
* @var boolean $protected
* @var yii\web\View $this
*/
if ($protected && count($item->getProtectedProperties()) == 0 || !$protected && count($item->getPublicProperties()) == 0) {
if ($protected && count($type->getProtectedProperties()) == 0 || !$protected && count($type->getPublicProperties()) == 0) {
return;
} ?>
@ -28,9 +28,9 @@ if ($protected && count($item->getProtectedProperties()) == 0 || !$protected &&
<tr>
<th>Property</th><th>Type</th><th>Description</th><th>Defined By</th>
</tr>
<?php foreach($item->properties as $property): ?>
<?php foreach($type->properties as $property): ?>
<?php if($protected && $property->visibility == 'protected' || !$protected && $property->visibility != 'protected'): ?>
<tr<?= $property->definedBy != $item->name ? ' class="inherited"' : '' ?> id="<?= $property->name ?>">
<tr<?= $property->definedBy != $type->name ? ' class="inherited"' : '' ?> id="<?= $property->name ?>">
<td><?php echo $this->context->subjectLink($property); ?></td>
<td><?php echo $this->context->typeLink($property->types); ?></td>
<td><?php echo $property->shortDescription; ?></td>

98
extensions/yii/apidoc/views/type.php

@ -0,0 +1,98 @@
<?php
use yii\apidoc\models\ClassDoc;
use yii\apidoc\models\InterfaceDoc;
use yii\apidoc\models\TraitDoc;
/**
* @var ClassDoc|InterfaceDoc|TraitDoc $type
* @var yii\web\View $this
* @var \yii\apidoc\components\OfflineRenderer $renderer
*/
$renderer = $this->context;
?>
<h1><?php
if ($type instanceof InterfaceDoc) {
echo 'Interface ';
} elseif ($type instanceof TraitDoc) {
echo 'Trait ';
} else {
if ($type->isFinal) {
echo 'Final ';
}
if ($type->isAbstract) {
echo 'Abstract ';
}
echo 'Class ';
}
echo $type->name;
?></h1>
<div id="nav">
<a href="index.html">All Classes</a>
<?php if(!($type instanceof InterfaceDoc) && !empty($type->properties)): ?>
| <a href="#properties">Properties</a>
<?php endif; ?>
<?php if(!empty($type->methods)): ?>
| <a href="#methods">Methods</a>
<?php endif; ?>
<?php if($type instanceof ClassDoc && !empty($type->events)): ?>
| <a href="#events">Events</a>
<?php endif; ?>
<?php if($type instanceof ClassDoc && !empty($type->constants)): ?>
| <a href="#constants">Constants</a>
<?php endif; ?>
</div>
<table class="summaryTable docClass">
<colgroup>
<col class="col-name" />
<col class="col-value" />
</colgroup>
<?php if ($type instanceof ClassDoc): ?>
<tr><th>Inheritance</th><td><?= $renderer->renderInheritance($type) ?></td></tr>
<?php endif; ?>
<?php if ($type instanceof ClassDoc && !empty($type->interfaces)): ?>
<tr><th>Implements</th><td><?= $renderer->renderInterfaces($type->interfaces) ?></td></tr>
<?php endif; ?>
<?php if(!($type instanceof InterfaceDoc) && !empty($type->traits)): ?>
<tr><th>Uses Traits</th><td><?= $renderer->renderTraits($type->traits) ?></td></tr>
<?php endif; ?>
<?php if($type instanceof ClassDoc && !empty($type->subclasses)): ?>
<tr><th>Subclasses</th><td><?= $renderer->renderClasses($type->subclasses) ?></td></tr>
<?php endif; ?>
<?php if ($type instanceof InterfaceDoc && !empty($type->implementedBy)): ?>
<tr><th>Implemented by</th><td><?= $renderer->renderClasses($type->implementedBy) ?></td></tr>
<?php endif; ?>
<?php if ($type instanceof TraitDoc && !empty($type->usedBy)): ?>
<tr><th>Implemented by</th><td><?= $renderer->renderClasses($type->usedBy) ?></td></tr>
<?php endif; ?>
<?php if(!empty($type->since)): ?>
<tr><th>Available since version</th><td><?= $type->since ?></td></tr>
<?php endif; ?>
<tr>
<th>Source Code</th>
<td><?php // TODO echo $this->renderSourceLink($type->sourcePath) ?></td>
</tr>
</table>
<div id="classDescription">
<strong><?= $type->shortDescription ?></strong>
<p><?= nl2br($type->description) ?></p>
</div>
<a name="properties"></a>
<?= $this->render('propertySummary', ['type' => $type,'protected' => false]) ?>
<?= $this->render('propertySummary', ['type' => $type,'protected' => true]) ?>
<a name="methods"></a>
<?= $this->render('methodSummary', ['type' => $type, 'protected' => false]) ?>
<?= $this->render('methodSummary', ['type' => $type, 'protected' => true]) ?>
<a name="events"></a>
<?= $this->render('eventSummary', ['type' => $type]) ?>
<a name="constants"></a>
<?= $this->render('constSummary', ['type' => $type]) ?>
<?php //$this->renderPartial('propertyDetails',array('type'=>$type)); ?>
<?php //$this->renderPartial('methodDetails',array('type'=>$type)); ?>
Loading…
Cancel
Save