diff --git a/extensions/apidoc/models/FunctionDoc.php b/extensions/apidoc/models/FunctionDoc.php index 2befe0a198..5e6e945fbd 100644 --- a/extensions/apidoc/models/FunctionDoc.php +++ b/extensions/apidoc/models/FunctionDoc.php @@ -73,7 +73,7 @@ class FunctionDoc extends BaseDoc } elseif ($tag instanceof ReturnTag) { $this->returnType = $tag->getType(); $this->returnTypes = $tag->getTypes(); - $this->return = $tag->getDescription(); + $this->return = ucfirst($tag->getDescription()); unset($this->tags[$i]); } } diff --git a/extensions/apidoc/renderers/BaseRenderer.php b/extensions/apidoc/renderers/BaseRenderer.php index ce0d4e0755..67e1acf8c0 100644 --- a/extensions/apidoc/renderers/BaseRenderer.php +++ b/extensions/apidoc/renderers/BaseRenderer.php @@ -57,9 +57,10 @@ abstract class BaseRenderer extends Component * @param ClassDoc|InterfaceDoc|TraitDoc|ClassDoc[]|InterfaceDoc[]|TraitDoc[] $types * @param string $title a title to be used for the link TODO check whether [[yii\...|Class]] is supported * @param BaseDoc $context + * @param array $options additional HTML attributes for the link. * @return string */ - public function createTypeLink($types, $context = null, $title = null) + public function createTypeLink($types, $context = null, $title = null, $options = []) { if (!is_array($types)) { $types = [$types]; @@ -103,9 +104,9 @@ abstract class BaseRenderer extends Component // check if it is PHP internal class if (((class_exists($type, false) || interface_exists($type, false) || trait_exists($type, false)) && ($reflection = new \ReflectionClass($type)) && $reflection->isInternal())) { - $links[] = $this->generateLink($linkText, 'http://www.php.net/class.' . strtolower(ltrim($type, '\\'))) . $postfix; + $links[] = $this->generateLink($linkText, 'http://www.php.net/class.' . strtolower(ltrim($type, '\\')), $options) . $postfix; } elseif (in_array($type, $phpTypes)) { - $links[] = $this->generateLink($linkText, 'http://www.php.net/language.types.' . strtolower(ltrim($type, '\\'))) . $postfix; + $links[] = $this->generateLink($linkText, 'http://www.php.net/language.types.' . strtolower(ltrim($type, '\\')), $options) . $postfix; } else { $links[] = $type; } @@ -114,10 +115,10 @@ abstract class BaseRenderer extends Component if ($title !== null) { $linkText = $title; } - $links[] = $this->generateLink($linkText, $this->generateApiUrl($type->name)) . $postfix; + $links[] = $this->generateLink($linkText, $this->generateApiUrl($type->name), $options) . $postfix; } } - return implode(' | ', $links); + return implode('|', $links); } @@ -125,9 +126,10 @@ abstract class BaseRenderer extends Component * creates a link to a subject * @param PropertyDoc|MethodDoc|ConstDoc|EventDoc $subject * @param string $title + * @param array $options additional HTML attributes for the link. * @return string */ - public function createSubjectLink($subject, $title = null) + public function createSubjectLink($subject, $title = null, $options = []) { if ($title === null) { if ($subject instanceof MethodDoc) { @@ -146,7 +148,7 @@ abstract class BaseRenderer extends Component $link .= '#' . $subject->name; } $link .= '-detail'; - return Html::a($title, null, ['href' => $link]); + return $this->generateLink($title, $link, $options); } } @@ -175,9 +177,10 @@ abstract class BaseRenderer extends Component * generate link markup * @param $text * @param $href + * @param array $options additional HTML attributes for the link. * @return mixed */ - protected abstract function generateLink($text, $href); + protected abstract function generateLink($text, $href, $options = []); /** * Generate an url to a type in apidocs diff --git a/extensions/apidoc/templates/bootstrap/assets/css/style.css b/extensions/apidoc/templates/bootstrap/assets/css/style.css index 03c8f19f85..8833636680 100644 --- a/extensions/apidoc/templates/bootstrap/assets/css/style.css +++ b/extensions/apidoc/templates/bootstrap/assets/css/style.css @@ -3,6 +3,10 @@ body { height: 100%; } +.guide-content, .api-content { + max-width: 1250px; +} + .wrap { min-height: 100%; height: auto; @@ -35,9 +39,14 @@ body { color: #fff; } -.signature, .signature2 { - padding: 3px; +.signature, .table-striped > tbody > tr > td.signature { + margin: 10px 0 10px 0; + padding: 8px; + color: #000000; + background: rgba(230, 236, 255, 0.81); + border: 1px rgba(191, 207, 255, 0.81) solid; + font-family: "courier new", "times new roman", monospace; line-height: 1.3em; white-space: pre-line; @@ -45,12 +54,6 @@ body { word-break: break-all; } -.signature { - margin: 10px 0 10px 0; - background: #E6ECFF; - border: 1px #BFCFFF solid; -} - blockquote { font-size: 14px; } @@ -59,7 +62,50 @@ 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%; } +table.detail-table .param-name-col { width: 15%; min-width: 100px; } +table.detail-table .param-type-col { width: 15%; min-width: 150px; } +table.detail-table .param-desc-col { width: 70%; } +table.summary-table .col-method { width: 20%; } +table.summary-table .col-property { width: 20%; } +table.summary-table .col-const { width: 20%; } +table.summary-table .col-event { width: 20%; } +table.summary-table .col-defined { width: 15%; } + +.detail-header { + margin-top: 30px; +} + +.doc-description { + border-left: solid 1px #ddd; + border-right: solid 1px #ddd; + padding: 10px 8px; + margin: 0; +} + +.event-doc .doc-description { + border-bottom: solid 1px #ddd; +} + +.doc-description p:last-child { + margin-bottom: 0; +} + +.tool-link { + float: right; + color: #ddd; + margin: 0 8px; +} + +.icon-hash:before { + content: '#'; + font-size: 32px; + font-weight: bold; + /*top: -10px;*/ + line-height: 0.5; +} + +.tool-link:hover { + color: #bbb; + text-decoration: none; +} \ No newline at end of file diff --git a/extensions/apidoc/templates/bootstrap/layouts/api.php b/extensions/apidoc/templates/bootstrap/layouts/api.php index d6a0002290..b7a5291f3d 100644 --- a/extensions/apidoc/templates/bootstrap/layouts/api.php +++ b/extensions/apidoc/templates/bootstrap/layouts/api.php @@ -44,7 +44,7 @@ $this->beginContent('@yii/apidoc/templates/bootstrap/layouts/main.php'); ?> 'view' => $this, ])?> -
+
diff --git a/extensions/apidoc/templates/bootstrap/layouts/guide.php b/extensions/apidoc/templates/bootstrap/layouts/guide.php index 0cad275014..941dc7002b 100644 --- a/extensions/apidoc/templates/bootstrap/layouts/guide.php +++ b/extensions/apidoc/templates/bootstrap/layouts/guide.php @@ -32,7 +32,7 @@ $this->beginContent('@yii/apidoc/templates/bootstrap/layouts/main.php'); ?> 'view' => $this, ]) ?> -
+
diff --git a/extensions/apidoc/templates/html/ApiRenderer.php b/extensions/apidoc/templates/html/ApiRenderer.php index d78d22ecae..06dcab5873 100644 --- a/extensions/apidoc/templates/html/ApiRenderer.php +++ b/extensions/apidoc/templates/html/ApiRenderer.php @@ -246,8 +246,8 @@ class ApiRenderer extends BaseApiRenderer implements ViewContextInterface return ($method->isReturnByReference ? '&' : '') . ($method->returnType === null ? 'void' : $this->createTypeLink($method->returnTypes)) - . ' ' . $this->createSubjectLink($method, $method->name) - . ApiMarkdown::highlight('( ' . implode(', ', $params) . ' )', 'php'); + . ' ' . $this->createSubjectLink($method, $method->name) . '' + . ApiMarkdown::highlight(str_replace(' ', ' ', '( ' . implode(', ', $params) . ' )'), 'php'); } public function generateApiUrl($typeName) @@ -271,14 +271,12 @@ class ApiRenderer extends BaseApiRenderer implements ViewContextInterface } /** - * generate link markup - * @param $text - * @param $href - * @return mixed + * @inheritdoc */ - protected function generateLink($text, $href) + protected function generateLink($text, $href, $options = []) { - return Html::a($text, null, ['href' => $href]); + $options['href'] = $href; + return Html::a($text, null, $options); } public function getSourceUrl($type) diff --git a/extensions/apidoc/templates/html/GuideRenderer.php b/extensions/apidoc/templates/html/GuideRenderer.php index a5d4451ed6..2ac7fd1ddb 100644 --- a/extensions/apidoc/templates/html/GuideRenderer.php +++ b/extensions/apidoc/templates/html/GuideRenderer.php @@ -138,14 +138,12 @@ abstract class GuideRenderer extends BaseGuideRenderer } /** - * generate link markup - * @param $text - * @param $href - * @return mixed + * @inheritdoc */ - protected function generateLink($text, $href) + protected function generateLink($text, $href, $options = []) { - return Html::a($text, null, ['href' => $href]); + $options['href'] = $href; + return Html::a($text, null, $options); } /** diff --git a/extensions/apidoc/templates/html/views/constSummary.php b/extensions/apidoc/templates/html/views/constSummary.php index f5c90ec269..a85df81471 100644 --- a/extensions/apidoc/templates/html/views/constSummary.php +++ b/extensions/apidoc/templates/html/views/constSummary.php @@ -18,27 +18,28 @@ if (empty($type->constants)) { $constants = $type->constants; ArrayHelper::multisort($constants, 'name'); ?> -
-

Constants

+
+

Constants

-

Hide inherited constants

+

Hide inherited constants

- -- - - - - - - - - definedBy != $type->name ? ' class="inherited"' : '' ?> id="name ?>"> - - - - +
ConstantValueDescriptionDefined By
name ?>value ?>shortDescription . "\n" . $constant->description, $constant->definedBy, true) ?>createTypeLink($constant->definedBy) ?>
+ + + + + + + + - -
ConstantValueDescriptionDefined By
+ + definedBy != $type->name ? ' class="inherited"' : '' ?> id="name ?>"> + name ?> + value ?> + shortDescription . "\n" . $constant->description, $constant->definedBy, true) ?> + createTypeLink($constant->definedBy) ?> + + +
\ No newline at end of file diff --git a/extensions/apidoc/templates/html/views/eventDetails.php b/extensions/apidoc/templates/html/views/eventDetails.php index c2aa217145..f3ecb9ae87 100644 --- a/extensions/apidoc/templates/html/views/eventDetails.php +++ b/extensions/apidoc/templates/html/views/eventDetails.php @@ -7,8 +7,11 @@ use yii\helpers\ArrayHelper; /** * @var ClassDoc $type * @var yii\web\View $this + * @var \yii\apidoc\templates\html\ApiRenderer $renderer */ +$renderer = $this->context; + $events = $type->getNativeEvents(); if (empty($events)) { return; @@ -16,10 +19,24 @@ if (empty($events)) { ArrayHelper::multisort($events, 'name'); ?>

Event Details

+ +
-
+
+ + createSubjectLink($event, '', [ + 'title' => 'direct link to this method', + 'class' => 'tool-link hash', + ]) ?> + + getSourceUrl($event->definedBy, $event->startLine)) !== null): ?> + + + + + name ?> - + event since)): ?> (available since version since ?>) @@ -27,13 +44,11 @@ ArrayHelper::multisort($events, 'name');
- - trigger->signature; ?> -
*/ ?> +
+ description, $type) ?> - description, $type) ?> - - render('seeAlso', ['object' => $event]) ?> + render('seeAlso', ['object' => $event]) ?> +
+
diff --git a/extensions/apidoc/templates/html/views/eventSummary.php b/extensions/apidoc/templates/html/views/eventSummary.php index 57fcef48a4..ce8c0ab3ed 100644 --- a/extensions/apidoc/templates/html/views/eventSummary.php +++ b/extensions/apidoc/templates/html/views/eventSummary.php @@ -18,32 +18,33 @@ if (empty($type->events)) { $events = $type->events; ArrayHelper::multisort($events, 'name'); ?> -
-

Events

+
+

Events

-

Hide inherited events

+

Hide inherited events

- -- - - - - - - - -definedBy != $type->name ? ' class="inherited"' : '' ?> id="name ?>"> - - - - - - -
EventTypeDescriptionDefined By
createSubjectLink($event) ?>createTypeLink($event->types) ?> - shortDescription, $event->definedBy, true) ?> - since)): ?> - (available since version since ?>) - - createTypeLink($event->definedBy) ?>
+ + + + + + + + + + + + definedBy != $type->name ? ' class="inherited"' : '' ?> id="name ?>"> + + + + + + +
EventTypeDescriptionDefined By
createSubjectLink($event) ?>createTypeLink($event->types) ?> + shortDescription, $event->definedBy, true) ?> + since)): ?> + (available since version since ?>) + + createTypeLink($event->definedBy) ?>
diff --git a/extensions/apidoc/templates/html/views/methodDetails.php b/extensions/apidoc/templates/html/views/methodDetails.php index 4e6066846c..a3db465ebf 100644 --- a/extensions/apidoc/templates/html/views/methodDetails.php +++ b/extensions/apidoc/templates/html/views/methodDetails.php @@ -21,11 +21,23 @@ ArrayHelper::multisort($methods, 'name'); ?>

Method Details

+
-
+
+ + createSubjectLink($method, '', [ + 'title' => 'direct link to this method', + 'class' => 'tool-link hash', + ]) ?> + + getSourceUrl($method->definedBy, $method->startLine)) !== null): ?> + + + + name ?>() - + visibility ?> method since)): ?> @@ -34,45 +46,42 @@ ArrayHelper::multisort($methods, 'name');
- - +
+

shortDescription, $type, true) ?>

+ + description, $type) ?> + + render('seeAlso', ['object' => $method]) ?> +
+ +
-
renderMethodSignature($method) ?>
-
+ params) || !empty($method->return) || !empty($method->exceptions)): ?> params as $param): ?> - - - + + + return)): ?> - - - + + + exceptions as $exception => $description): ?> - - - + + + - getSourceUrl($method->definedBy, $method->startLine)) !== null): ?> - - - -
renderMethodSignature($method) ?>
name, 'php') ?>createTypeLink($param->types) ?>description, $type) ?>name, 'php') ?>createTypeLink($param->types) ?>description, $type) ?>
createTypeLink($method->returnTypes) ?>return, $type) ?>returncreateTypeLink($method->returnTypes) ?>return, $type) ?>
createTypeLink($exception) ?>throwscreateTypeLink($exception) ?>
Source Code:
renderPartial('sourceCode',array('object'=>$method)); ?> -

shortDescription, $type, true) ?>

- description, $type) ?> - - render('seeAlso', ['object' => $method]) ?> - +
diff --git a/extensions/apidoc/templates/html/views/methodSummary.php b/extensions/apidoc/templates/html/views/methodSummary.php index b800eb3a4d..9d264aa63c 100644 --- a/extensions/apidoc/templates/html/views/methodSummary.php +++ b/extensions/apidoc/templates/html/views/methodSummary.php @@ -19,12 +19,12 @@ if ($protected && count($type->getProtectedMethods()) == 0 || !$protected && cou return; } ?> -
+

Hide inherited methods

- +
diff --git a/extensions/apidoc/templates/html/views/propertyDetails.php b/extensions/apidoc/templates/html/views/propertyDetails.php index 63ca3025c8..17aa86475d 100644 --- a/extensions/apidoc/templates/html/views/propertyDetails.php +++ b/extensions/apidoc/templates/html/views/propertyDetails.php @@ -21,9 +21,22 @@ ArrayHelper::multisort($properties, 'name'); ?>

Property Details

+
-
+
+ + createSubjectLink($property, '', [ + 'title' => 'direct link to this method', + 'class' => 'tool-link hash', + ]) ?> + + getSourceUrl($property->definedBy, $property->startLine)) !== null): ?> + + + + + name ?> visibility ?> @@ -43,3 +56,4 @@ ArrayHelper::multisort($properties, 'name'); render('seeAlso', ['object' => $property]) ?> +
diff --git a/extensions/apidoc/templates/html/views/propertySummary.php b/extensions/apidoc/templates/html/views/propertySummary.php index 3fa31319c5..250c7eadaa 100644 --- a/extensions/apidoc/templates/html/views/propertySummary.php +++ b/extensions/apidoc/templates/html/views/propertySummary.php @@ -18,12 +18,12 @@ if ($protected && count($type->getProtectedProperties()) == 0 || !$protected && return; } ?> -
+
diff --git a/extensions/apidoc/templates/html/views/seeAlso.php b/extensions/apidoc/templates/html/views/seeAlso.php index 3752a4f93f..4fcbef9ad4 100644 --- a/extensions/apidoc/templates/html/views/seeAlso.php +++ b/extensions/apidoc/templates/html/views/seeAlso.php @@ -11,21 +11,22 @@ foreach ($object->tags as $tag) { if (get_class($tag) == 'phpDocumentor\Reflection\DocBlock\Tag\SeeTag') { $ref = $tag->getReference(); if (strpos($ref, '://') === false) { - $see[] = '[[' . $ref . ']]'; - } else { - $see[] = $ref; + $ref = '[[' . $ref . ']]'; } + $see[] = rtrim(\yii\apidoc\helpers\ApiMarkdown::process($ref . ' ' . $tag->getDescription(), $object->definedBy, true), ". \r\n"); } } if (empty($see)) { return; +} elseif (count($see) == 1) { + echo '

See also ' . reset($see) . '.

'; +} else { + echo '

See also:

    '; + foreach ($see as $ref) { + if (substr($ref, -1, 1) != '>') { + $ref .= '.'; + } + echo "
  • $ref
  • "; + } + echo '
'; } -?> -
-

See Also

-
    - -
  • definedBy, true) ?>
  • - -
-