Commit 595f55c5 by Carsten Brandt

api doc improvements

parent c815d0ce
......@@ -93,7 +93,7 @@ class ApiMarkdown extends GithubMarkdown
}
}
protected function highlight($code, $language)
public static function highlight($code, $language)
{
if ($language !== 'php') {
return htmlspecialchars($code, ENT_NOQUOTES, 'UTF-8');
......
......@@ -58,3 +58,8 @@ blockquote {
td p {
margin: 0;
}
table.detailTable .paramNameCol { width: 15%; min-width: 100px; }
table.detailTable .paramTypeCol { width: 15%; min-width: 150px; }
table.detailTable .paramDescCol { width: 70%; }
......@@ -7,6 +7,7 @@
namespace yii\apidoc\templates\html;
use yii\apidoc\helpers\ApiMarkdown;
use yii\apidoc\models\MethodDoc;
use yii\apidoc\models\PropertyDoc;
use yii\apidoc\models\ClassDoc;
......@@ -225,7 +226,8 @@ class ApiRenderer extends BaseApiRenderer implements ViewContextInterface
}
return implode('<br />', $sig);
}
return $this->createTypeLink($property->types) . ' ' . $property->name . ' = ' . ($property->defaultValue === null ? 'null' : $property->defaultValue);
return $this->createTypeLink($property->types) . ' ' . $this->createSubjectLink($property, $property->name) . ' '
. ApiMarkdown::highlight('= ' . ($property->defaultValue === null ? 'null' : $property->defaultValue), 'php');
}
/**
......@@ -244,9 +246,8 @@ class ApiRenderer extends BaseApiRenderer implements ViewContextInterface
return ($method->isReturnByReference ? '<b>&</b>' : '')
. ($method->returnType === null ? 'void' : $this->createTypeLink($method->returnTypes))
. ' ' . $this->createSubjectLink($method, $method->name) . '( '
. implode(', ', $params)
. ' )';
. ' ' . $this->createSubjectLink($method, $method->name)
. ApiMarkdown::highlight('( ' . implode(', ', $params) . ' )', 'php');
}
public function generateApiUrl($typeName)
......
......@@ -34,28 +34,28 @@ ArrayHelper::multisort($methods, 'name');
</span>
</div>
<table class="summaryTable table table-striped table-bordered table-hover">
<table class="detailTable table table-striped table-bordered table-hover">
<tr><td colspan="3">
<div class="signature2"><?= $renderer->renderMethodSignature($method) ?></div>
</td></tr>
<?php if (!empty($method->params) || !empty($method->return) || !empty($method->exceptions)): ?>
<?php foreach ($method->params as $param): ?>
<tr>
<td class="paramNameCol"><?= $param->name ?></td>
<td class="paramNameCol"><?= ApiMarkdown::highlight($param->name, 'php') ?></td>
<td class="paramTypeCol"><?= $renderer->createTypeLink($param->types) ?></td>
<td class="paramDescCol"><?= ApiMarkdown::process($param->description, $type) ?></td>
</tr>
<?php endforeach; ?>
<?php if (!empty($method->return)): ?>
<tr>
<td class="paramNameCol"><?= 'return'; ?></td>
<th class="paramNameCol"><?= 'return'; ?></th>
<td class="paramTypeCol"><?= $renderer->createTypeLink($method->returnTypes); ?></td>
<td class="paramDescCol"><?= ApiMarkdown::process($method->return, $type); ?></td>
</tr>
<?php endif; ?>
<?php foreach ($method->exceptions as $exception => $description): ?>
<tr>
<td class="paramNameCol"><?= 'throws' ?></td>
<th class="paramNameCol"><?= 'throws' ?></th>
<td class="paramTypeCol"><?= $renderer->createTypeLink($exception) ?></td>
<td class="paramDescCol"><?= ApiMarkdown::process($description, $type) ?></td>
</tr>
......
......@@ -31,7 +31,7 @@ class Widget extends Component implements ViewContextInterface
public static $counter = 0;
/**
* @var string the prefix to the automatically generated widget IDs.
* @see [[getId()]]
* @see getId()
*/
public static $autoIdPrefix = 'w';
......
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