Commit abceccfd by Carsten Brandt

improved APIdocs template by sorting all items

parent 0f7732e8
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
use yii\apidoc\helpers\Markdown; use yii\apidoc\helpers\Markdown;
use yii\apidoc\models\ClassDoc; use yii\apidoc\models\ClassDoc;
use yii\helpers\ArrayHelper;
/** /**
* @var ClassDoc $type * @var ClassDoc $type
* @var yii\web\View $this * @var yii\web\View $this
...@@ -9,7 +11,10 @@ use yii\apidoc\models\ClassDoc; ...@@ -9,7 +11,10 @@ use yii\apidoc\models\ClassDoc;
if (empty($type->constants)) { if (empty($type->constants)) {
return; return;
} ?> }
$constants = $type->constants;
ArrayHelper::multisort($constants, 'name');
?>
<div class="summary docConst"> <div class="summary docConst">
<h2>Constants</h2> <h2>Constants</h2>
...@@ -24,7 +29,7 @@ if (empty($type->constants)) { ...@@ -24,7 +29,7 @@ if (empty($type->constants)) {
<tr> <tr>
<th>Constant</th><th>Value</th><th>Description</th><th>Defined By</th> <th>Constant</th><th>Value</th><th>Description</th><th>Defined By</th>
</tr> </tr>
<?php foreach($type->constants as $constant): ?> <?php foreach($constants as $constant): ?>
<tr<?= $constant->definedBy != $type->name ? ' class="inherited"' : '' ?> id="<?= $constant->name ?>"> <tr<?= $constant->definedBy != $type->name ? ' class="inherited"' : '' ?> id="<?= $constant->name ?>">
<td><?= $constant->name ?><a name="<?= $constant->name ?>-detail"></a></td> <td><?= $constant->name ?><a name="<?= $constant->name ?>-detail"></a></td>
<td><?= $constant->value ?></td> <td><?= $constant->value ?></td>
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
use yii\apidoc\helpers\Markdown; use yii\apidoc\helpers\Markdown;
use yii\apidoc\models\ClassDoc; use yii\apidoc\models\ClassDoc;
use yii\helpers\ArrayHelper;
/** /**
* @var ClassDoc $type * @var ClassDoc $type
* @var yii\web\View $this * @var yii\web\View $this
...@@ -10,7 +12,9 @@ use yii\apidoc\models\ClassDoc; ...@@ -10,7 +12,9 @@ use yii\apidoc\models\ClassDoc;
$events = $type->getNativeEvents(); $events = $type->getNativeEvents();
if (empty($events)) { if (empty($events)) {
return; return;
} ?> }
ArrayHelper::multisort($events, 'name');
?>
<h2>Event Details</h2> <h2>Event Details</h2>
<?php foreach($events as $event): ?> <?php foreach($events as $event): ?>
<div class="detailHeader h3" id="<?= $event->name.'-detail' ?>"> <div class="detailHeader h3" id="<?= $event->name.'-detail' ?>">
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
use yii\apidoc\helpers\Markdown; use yii\apidoc\helpers\Markdown;
use yii\apidoc\models\ClassDoc; use yii\apidoc\models\ClassDoc;
use yii\helpers\ArrayHelper;
/** /**
* @var ClassDoc $type * @var ClassDoc $type
* @var yii\web\View $this * @var yii\web\View $this
...@@ -9,7 +11,10 @@ use yii\apidoc\models\ClassDoc; ...@@ -9,7 +11,10 @@ use yii\apidoc\models\ClassDoc;
if (empty($type->events)) { if (empty($type->events)) {
return; return;
} ?> }
$events = $type->events;
ArrayHelper::multisort($events, 'name');
?>
<div class="summary docEvent"> <div class="summary docEvent">
<h2>Events</h2> <h2>Events</h2>
...@@ -24,7 +29,7 @@ if (empty($type->events)) { ...@@ -24,7 +29,7 @@ if (empty($type->events)) {
<tr> <tr>
<th>Event</th><th>Type</th><th>Description</th><th>Defined By</th> <th>Event</th><th>Type</th><th>Description</th><th>Defined By</th>
</tr> </tr>
<?php foreach($type->events as $event): ?> <?php foreach($events as $event): ?>
<tr<?= $event->definedBy != $type->name ? ' class="inherited"' : '' ?> id="<?= $event->name ?>"> <tr<?= $event->definedBy != $type->name ? ' class="inherited"' : '' ?> id="<?= $event->name ?>">
<td><?= $this->context->subjectLink($event) ?></td> <td><?= $this->context->subjectLink($event) ?></td>
<td><?= $this->context->typeLink($event->types) ?></td> <td><?= $this->context->typeLink($event->types) ?></td>
......
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
use yii\apidoc\helpers\Markdown; use yii\apidoc\helpers\Markdown;
use yii\apidoc\models\ClassDoc; use yii\apidoc\models\ClassDoc;
use yii\apidoc\models\TraitDoc; use yii\apidoc\models\TraitDoc;
use yii\helpers\ArrayHelper;
/** /**
* @var ClassDoc|TraitDoc $type * @var ClassDoc|TraitDoc $type
* @var yii\web\View $this * @var yii\web\View $this
...@@ -11,7 +13,9 @@ use yii\apidoc\models\TraitDoc; ...@@ -11,7 +13,9 @@ use yii\apidoc\models\TraitDoc;
$methods = $type->getNativeMethods(); $methods = $type->getNativeMethods();
if (empty($methods)) { if (empty($methods)) {
return; return;
} ?> }
ArrayHelper::multisort($methods, 'name');
?>
<h2>Method Details</h2> <h2>Method Details</h2>
<?php foreach($methods as $method): ?> <?php foreach($methods as $method): ?>
......
...@@ -4,6 +4,8 @@ use yii\apidoc\helpers\Markdown; ...@@ -4,6 +4,8 @@ use yii\apidoc\helpers\Markdown;
use yii\apidoc\models\ClassDoc; use yii\apidoc\models\ClassDoc;
use yii\apidoc\models\InterfaceDoc; use yii\apidoc\models\InterfaceDoc;
use yii\apidoc\models\TraitDoc; use yii\apidoc\models\TraitDoc;
use yii\helpers\ArrayHelper;
/** /**
* @var ClassDoc|InterfaceDoc|TraitDoc $type * @var ClassDoc|InterfaceDoc|TraitDoc $type
* @var boolean $protected * @var boolean $protected
...@@ -28,7 +30,10 @@ if ($protected && count($type->getProtectedMethods()) == 0 || !$protected && cou ...@@ -28,7 +30,10 @@ if ($protected && count($type->getProtectedMethods()) == 0 || !$protected && cou
<tr> <tr>
<th>Method</th><th>Description</th><th>Defined By</th> <th>Method</th><th>Description</th><th>Defined By</th>
</tr> </tr>
<?php foreach($type->methods as $method): ?> <?php
$methods = $type->methods;
ArrayHelper::multisort($methods, 'name');
foreach($methods as $method): ?>
<?php if($protected && $method->visibility == 'protected' || !$protected && $method->visibility != 'protected'): ?> <?php if($protected && $method->visibility == 'protected' || !$protected && $method->visibility != 'protected'): ?>
<tr<?= $method->definedBy != $type->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><?= $this->context->subjectLink($method, $method->name.'()') ?></td>
......
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
use yii\apidoc\helpers\Markdown; use yii\apidoc\helpers\Markdown;
use yii\apidoc\models\ClassDoc; use yii\apidoc\models\ClassDoc;
use yii\apidoc\models\TraitDoc; use yii\apidoc\models\TraitDoc;
use yii\helpers\ArrayHelper;
/** /**
* @var ClassDoc|TraitDoc $type * @var ClassDoc|TraitDoc $type
* @var yii\web\View $this * @var yii\web\View $this
...@@ -11,7 +13,9 @@ use yii\apidoc\models\TraitDoc; ...@@ -11,7 +13,9 @@ use yii\apidoc\models\TraitDoc;
$properties = $type->getNativeProperties(); $properties = $type->getNativeProperties();
if (empty($properties)) { if (empty($properties)) {
return; return;
} ?> }
ArrayHelper::multisort($properties, 'name');
?>
<h2>Property Details</h2> <h2>Property Details</h2>
<?php foreach($properties as $property): ?> <?php foreach($properties as $property): ?>
......
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
use yii\apidoc\helpers\Markdown; use yii\apidoc\helpers\Markdown;
use yii\apidoc\models\ClassDoc; use yii\apidoc\models\ClassDoc;
use yii\apidoc\models\TraitDoc; use yii\apidoc\models\TraitDoc;
use yii\helpers\ArrayHelper;
/** /**
* @var ClassDoc|TraitDoc $type * @var ClassDoc|TraitDoc $type
* @var boolean $protected * @var boolean $protected
...@@ -28,7 +30,10 @@ if ($protected && count($type->getProtectedProperties()) == 0 || !$protected && ...@@ -28,7 +30,10 @@ if ($protected && count($type->getProtectedProperties()) == 0 || !$protected &&
<tr> <tr>
<th>Property</th><th>Type</th><th>Description</th><th>Defined By</th> <th>Property</th><th>Type</th><th>Description</th><th>Defined By</th>
</tr> </tr>
<?php foreach($type->properties as $property): ?> <?php
$properties = $type->properties;
ArrayHelper::multisort($properties, 'name');
foreach($properties as $property): ?>
<?php if($protected && $property->visibility == 'protected' || !$protected && $property->visibility != 'protected'): ?> <?php if($protected && $property->visibility == 'protected' || !$protected && $property->visibility != 'protected'): ?>
<tr<?= $property->definedBy != $type->name ? ' class="inherited"' : '' ?> id="<?= $property->name ?>"> <tr<?= $property->definedBy != $type->name ? ' class="inherited"' : '' ?> id="<?= $property->name ?>">
<td><?= $this->context->subjectLink($property) ?></td> <td><?= $this->context->subjectLink($property) ?></td>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment