diff --git a/CHANGELOG.md b/CHANGELOG.md index 56442966..891c04fd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ Yii Framework 2 apidoc extension Change Log - Enh #196: Added support for PHPDoc inline links (arogachev) - Enh #147: Added feature of viewing method source code without external links (arogachev) - Bug #168: Fixed handling of inheritance (arogachev) +- Enh #140: Added support for multiple "since" tags (arogachev) - Bug #240: Fixed a bug when a "virtual" / "magic" property's full description was displayed instead of preview in properties list (arogachev) - Bug #239: Do not show a "virtual" / "magic" methods's full description if it matches short description (arogachev) diff --git a/models/BaseDoc.php b/models/BaseDoc.php index e4480f35..bf032c13 100644 --- a/models/BaseDoc.php +++ b/models/BaseDoc.php @@ -36,7 +36,14 @@ class BaseDoc extends BaseObject public $endLine; public $shortDescription; public $description; + /** + * @var string|null Available since this version. + */ public $since; + /** + * @var array A mapping where keys are versions and values are descriptions. + */ + public $sinceMap = []; public $deprecatedSince; public $deprecatedReason; /** @@ -183,11 +190,19 @@ public function __construct($reflector = null, $context = null, $config = []) $this->tags = $docBlock->getTags(); foreach ($this->tags as $i => $tag) { if ($tag instanceof Since) { - $this->since = $tag->getVersion(); + $description = (string) $tag->getDescription(); + if (!$this->since && !$this->sinceMap && !$description) { + $this->since = $tag->getVersion(); + } + + if ($description) { + $this->sinceMap[$tag->getVersion()] = $description; + } + unset($this->tags[$i]); } elseif ($tag instanceof Deprecated) { $this->deprecatedSince = $tag->getVersion(); - $this->deprecatedReason = $tag->getDescription(); + $this->deprecatedReason = (string) $tag->getDescription(); unset($this->tags[$i]); } elseif ($tag->getName() === 'todo') { $this->todos[] = $tag; diff --git a/templates/bootstrap/assets/css/style.css b/templates/bootstrap/assets/css/style.css index 6979f713..f584c407 100644 --- a/templates/bootstrap/assets/css/style.css +++ b/templates/bootstrap/assets/css/style.css @@ -274,6 +274,12 @@ tr.deprecated th { background: lightpink; } +/* Changelog */ + +.changelog { + border: 1px solid #ddd !important; +} + /* Todos */ .todo { diff --git a/templates/html/views/changelog.php b/templates/html/views/changelog.php new file mode 100644 index 00000000..8f4b1ff6 --- /dev/null +++ b/templates/html/views/changelog.php @@ -0,0 +1,25 @@ + + +sinceMap) { ?> + + + + + + + + + sinceMap as $version => $description) { ?> + + + + + + +
VersionDescription
+ diff --git a/templates/html/views/eventDetails.php b/templates/html/views/eventDetails.php index 16c05532..8a08cfae 100644 --- a/templates/html/views/eventDetails.php +++ b/templates/html/views/eventDetails.php @@ -57,5 +57,7 @@ render('seeAlso', ['object' => $event]) ?> + render('@yii/apidoc/templates/html/views/changelog', ['doc' => $event]) ?> + diff --git a/templates/html/views/methodDetails.php b/templates/html/views/methodDetails.php index 72500f7b..605158b6 100644 --- a/templates/html/views/methodDetails.php +++ b/templates/html/views/methodDetails.php @@ -91,25 +91,11 @@ - sourceCode; - $collapseId = 'collapse' . ucfirst($method->name); - ?> - -

- -

-
-
-
-                highlight('php', $sourceCode)->value ?>
-            
-
-
- + render('@yii/apidoc/templates/html/views/changelog', ['doc' => $method]) ?> + render( + '@yii/apidoc/templates/html/views/methodSourceCode', + ['method' => $method, 'highlighter' => $highlighter] + ) ?> render('@yii/apidoc/templates/html/views/todos', ['doc' => $method]) ?> diff --git a/templates/html/views/methodSourceCode.php b/templates/html/views/methodSourceCode.php new file mode 100644 index 00000000..95105cae --- /dev/null +++ b/templates/html/views/methodSourceCode.php @@ -0,0 +1,24 @@ +sourceCode; +$collapseId = 'collapse' . ucfirst($method->name); +?> + +

+ +

+
+
+
+            highlight('php', $sourceCode)->value ?>
+        
+
+
diff --git a/templates/html/views/propertyDetails.php b/templates/html/views/propertyDetails.php index 43fb8d4f..90cfed96 100644 --- a/templates/html/views/propertyDetails.php +++ b/templates/html/views/propertyDetails.php @@ -64,6 +64,7 @@
renderPropertySignature($property, $type); ?>
+ render('@yii/apidoc/templates/html/views/changelog', ['doc' => $property]) ?> render('@yii/apidoc/templates/html/views/todos', ['doc' => $property]) ?> diff --git a/templates/html/views/type.php b/templates/html/views/type.php index 30ad64ef..008128a6 100644 --- a/templates/html/views/type.php +++ b/templates/html/views/type.php @@ -91,6 +91,8 @@ render('seeAlso', ['object' => $type]) ?> +render('@yii/apidoc/templates/html/views/changelog', ['doc' => $type]) ?> + render('@yii/apidoc/templates/html/views/propertySummary', ['type' => $type, 'protected' => false]) ?> render('@yii/apidoc/templates/html/views/propertySummary', ['type' => $type, 'protected' => true]) ?>