mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-15 13:58:24 +08:00
fixed apidoc context for markdown rendering
This commit is contained in:
@@ -34,6 +34,10 @@ class Markdown extends \yii\helpers\Markdown
|
|||||||
*/
|
*/
|
||||||
public static function process($content, $context = null)
|
public static function process($content, $context = null)
|
||||||
{
|
{
|
||||||
|
if (is_string($context)) {
|
||||||
|
$context = static::$renderer->context->getType($context);
|
||||||
|
}
|
||||||
|
|
||||||
$content = trim(parent::process($content, []));
|
$content = trim(parent::process($content, []));
|
||||||
if (!strncmp($content, '<p>', 3) && substr($content, -4, 4) == '</p>') {
|
if (!strncmp($content, '<p>', 3) && substr($content, -4, 4) == '</p>') {
|
||||||
$content = substr($content, 3, -4);
|
$content = substr($content, 3, -4);
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ ArrayHelper::multisort($constants, 'name');
|
|||||||
<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>
|
||||||
<td><?= Markdown::process($constant->shortDescription . "\n" . $constant->description, $type) ?></td>
|
<td><?= Markdown::process($constant->shortDescription . "\n" . $constant->description, $constant->definedBy) ?></td>
|
||||||
<td><?= $this->context->typeLink($constant->definedBy) ?></td>
|
<td><?= $this->context->typeLink($constant->definedBy) ?></td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ ArrayHelper::multisort($events, '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>
|
||||||
<td>
|
<td>
|
||||||
<?= Markdown::process($event->shortDescription, $type) ?>
|
<?= Markdown::process($event->shortDescription, $event->definedBy) ?>
|
||||||
<?php if(!empty($event->since)): ?>
|
<?php if(!empty($event->since)): ?>
|
||||||
(available since version <?php echo $event->since; ?>)
|
(available since version <?php echo $event->since; ?>)
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ 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>
|
||||||
<td><?= Markdown::process($method->shortDescription, $type) ?></td>
|
<td><?= Markdown::process($method->shortDescription, $method->definedBy) ?></td>
|
||||||
<td><?= $this->context->typeLink($method->definedBy, $type) ?></td>
|
<td><?= $this->context->typeLink($method->definedBy, $type) ?></td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ foreach($properties as $property): ?>
|
|||||||
<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>
|
||||||
<td><?= $this->context->typeLink($property->types) ?></td>
|
<td><?= $this->context->typeLink($property->types) ?></td>
|
||||||
<td><?= Markdown::process($property->shortDescription, $type) ?></td>
|
<td><?= Markdown::process($property->shortDescription, $property->definedBy) ?></td>
|
||||||
<td><?= $this->context->typeLink($property->definedBy) ?></td>
|
<td><?= $this->context->typeLink($property->definedBy) ?></td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ if (empty($see)) {
|
|||||||
<h4>See Also</h4>
|
<h4>See Also</h4>
|
||||||
<ul>
|
<ul>
|
||||||
<?php foreach($see as $ref): ?>
|
<?php foreach($see as $ref): ?>
|
||||||
<li><?= \yii\apidoc\helpers\Markdown::process($ref, $this->context->context->getType($object->definedBy)) ?></li>
|
<li><?= \yii\apidoc\helpers\Markdown::process($ref, $object->definedBy) ?></li>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user