From 595f55c504bf5bada6ac57eb6f400b4ab6f430fd Mon Sep 17 00:00:00 2001 From: Carsten Brandt Date: Sat, 8 Mar 2014 14:20:19 +0100 Subject: [PATCH] api doc improvements --- extensions/apidoc/helpers/ApiMarkdown.php | 2 +- .../apidoc/templates/bootstrap/assets/css/style.css | 7 ++++++- extensions/apidoc/templates/html/ApiRenderer.php | 9 +++++---- extensions/apidoc/templates/html/views/methodDetails.php | 8 ++++---- framework/base/Widget.php | 2 +- 5 files changed, 17 insertions(+), 11 deletions(-) diff --git a/extensions/apidoc/helpers/ApiMarkdown.php b/extensions/apidoc/helpers/ApiMarkdown.php index 80ba5faf12..690323d8aa 100644 --- a/extensions/apidoc/helpers/ApiMarkdown.php +++ b/extensions/apidoc/helpers/ApiMarkdown.php @@ -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'); diff --git a/extensions/apidoc/templates/bootstrap/assets/css/style.css b/extensions/apidoc/templates/bootstrap/assets/css/style.css index 624014638f..03c8f19f85 100644 --- a/extensions/apidoc/templates/bootstrap/assets/css/style.css +++ b/extensions/apidoc/templates/bootstrap/assets/css/style.css @@ -57,4 +57,9 @@ blockquote { td p { margin: 0; -} \ No newline at end of file +} + +table.detailTable .paramNameCol { width: 15%; min-width: 100px; } +table.detailTable .paramTypeCol { width: 15%; min-width: 150px; } +table.detailTable .paramDescCol { width: 70%; } + diff --git a/extensions/apidoc/templates/html/ApiRenderer.php b/extensions/apidoc/templates/html/ApiRenderer.php index b83b0e6a00..de0a9ff9c9 100644 --- a/extensions/apidoc/templates/html/ApiRenderer.php +++ b/extensions/apidoc/templates/html/ApiRenderer.php @@ -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('
', $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 ? '&' : '') . ($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) diff --git a/extensions/apidoc/templates/html/views/methodDetails.php b/extensions/apidoc/templates/html/views/methodDetails.php index 04f208e3e0..aca46fe4d5 100644 --- a/extensions/apidoc/templates/html/views/methodDetails.php +++ b/extensions/apidoc/templates/html/views/methodDetails.php @@ -34,28 +34,28 @@ ArrayHelper::multisort($methods, 'name'); - +
params) || !empty($method->return) || !empty($method->exceptions)): ?> params as $param): ?> - + return)): ?> - + exceptions as $exception => $description): ?> - + diff --git a/framework/base/Widget.php b/framework/base/Widget.php index 8cb20dcbac..2f45689af0 100644 --- a/framework/base/Widget.php +++ b/framework/base/Widget.php @@ -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';
renderMethodSignature($method) ?>
name ?>name, 'php') ?> createTypeLink($param->types) ?> description, $type) ?>
createTypeLink($method->returnTypes); ?> return, $type); ?>
createTypeLink($exception) ?>