mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-29 22:21:33 +08:00
@@ -127,4 +127,20 @@ class BaseDoc extends Object
|
|||||||
// $lines = file(YII_PATH . $this->sourcePath);
|
// $lines = file(YII_PATH . $this->sourcePath);
|
||||||
// return implode("", array_slice($lines, $this->startLine - 1, $this->endLine - $this->startLine + 1));
|
// return implode("", array_slice($lines, $this->startLine - 1, $this->endLine - $this->startLine + 1));
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
public static function extractFirstSentence($text)
|
||||||
|
{
|
||||||
|
if (mb_strlen($text) > 4 && ($pos = mb_strpos($text, '.', 4, 'utf-8')) !== false) {
|
||||||
|
$sentence = mb_substr($text, 0, $pos + 1, 'utf-8');
|
||||||
|
if (mb_strlen($text) >= $pos + 3) {
|
||||||
|
$abbrev = mb_substr($text, $pos - 1, 4);
|
||||||
|
if ($abbrev === 'e.g.' || $abbrev === 'i.e.') { // do not break sentence after abbreviation
|
||||||
|
$sentence .= static::extractFirstSentence(mb_substr($text, $pos + 1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $sentence;
|
||||||
|
} else {
|
||||||
|
return $text;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -289,8 +289,7 @@ class Context extends Component
|
|||||||
'isStatic' => false,
|
'isStatic' => false,
|
||||||
'type' => $method->returnType,
|
'type' => $method->returnType,
|
||||||
'types' => $method->returnTypes,
|
'types' => $method->returnTypes,
|
||||||
'shortDescription' => (($pos = strpos($method->return, '.')) !== false) ?
|
'shortDescription' => BaseDoc::extractFirstSentence($method->return),
|
||||||
substr($method->return, 0, $pos) : $method->return,
|
|
||||||
'description' => $method->return,
|
'description' => $method->return,
|
||||||
'getter' => $method
|
'getter' => $method
|
||||||
// TODO set default value
|
// TODO set default value
|
||||||
@@ -319,8 +318,7 @@ class Context extends Component
|
|||||||
'isStatic' => false,
|
'isStatic' => false,
|
||||||
'type' => $param->type,
|
'type' => $param->type,
|
||||||
'types' => $param->types,
|
'types' => $param->types,
|
||||||
'shortDescription' => (($pos = strpos($param->description, '.')) !== false) ?
|
'shortDescription' => BaseDoc::extractFirstSentence($param->description),
|
||||||
substr($param->description, 0, $pos) : $param->description,
|
|
||||||
'description' => $param->description,
|
'description' => $param->description,
|
||||||
'setter' => $method
|
'setter' => $method
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -39,11 +39,7 @@ class EventDoc extends ConstDoc
|
|||||||
$this->type = $eventTag->getType();
|
$this->type = $eventTag->getType();
|
||||||
$this->types = $eventTag->getTypes();
|
$this->types = $eventTag->getTypes();
|
||||||
$this->description = ucfirst($eventTag->getDescription());
|
$this->description = ucfirst($eventTag->getDescription());
|
||||||
if (($pos = strpos($this->description, '.')) !== false) {
|
$this->shortDescription = BaseDoc::extractFirstSentence($this->description);
|
||||||
$this->shortDescription = substr($this->description, 0, $pos);
|
|
||||||
} else {
|
|
||||||
$this->shortDescription = $this->description;
|
|
||||||
}
|
|
||||||
unset($this->tags[$i]);
|
unset($this->tags[$i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,11 +72,7 @@ class PropertyDoc extends BaseDoc
|
|||||||
$this->type = $tag->getType();
|
$this->type = $tag->getType();
|
||||||
$this->types = $tag->getTypes();
|
$this->types = $tag->getTypes();
|
||||||
$this->description = ucfirst($tag->getDescription());
|
$this->description = ucfirst($tag->getDescription());
|
||||||
if (($pos = strpos($this->description, '.')) !== false) {
|
$this->shortDescription = BaseDoc::extractFirstSentence($this->description);
|
||||||
$this->shortDescription = substr($this->description, 0, $pos + 1);
|
|
||||||
} else {
|
|
||||||
$this->shortDescription = $this->description;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (empty($this->shortDescription) && $context !== null && !$hasInheritdoc) {
|
if (empty($this->shortDescription) && $context !== null && !$hasInheritdoc) {
|
||||||
|
|||||||
@@ -5,6 +5,8 @@
|
|||||||
* @var yii\web\View $this
|
* @var yii\web\View $this
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
$type = $object instanceof \yii\apidoc\models\TypeDoc ? $object : $object->definedBy;
|
||||||
|
|
||||||
$see = [];
|
$see = [];
|
||||||
foreach ($object->tags as $tag) {
|
foreach ($object->tags as $tag) {
|
||||||
/** @var $tag phpDocumentor\Reflection\DocBlock\Tag\SeeTag */
|
/** @var $tag phpDocumentor\Reflection\DocBlock\Tag\SeeTag */
|
||||||
@@ -13,7 +15,7 @@ foreach ($object->tags as $tag) {
|
|||||||
if (strpos($ref, '://') === false) {
|
if (strpos($ref, '://') === false) {
|
||||||
$ref = '[[' . $ref . ']]';
|
$ref = '[[' . $ref . ']]';
|
||||||
}
|
}
|
||||||
$see[] = rtrim(\yii\apidoc\helpers\ApiMarkdown::process($ref . ' ' . $tag->getDescription(), $object->definedBy, true), ". \r\n");
|
$see[] = rtrim(\yii\apidoc\helpers\ApiMarkdown::process($ref . ' ' . $tag->getDescription(), $type, true), ". \r\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (empty($see)) {
|
if (empty($see)) {
|
||||||
|
|||||||
@@ -80,8 +80,10 @@ $renderer = $this->context;
|
|||||||
</table>
|
</table>
|
||||||
|
|
||||||
<div id="classDescription">
|
<div id="classDescription">
|
||||||
<strong><?= ApiMarkdown::process($type->shortDescription, $type, true) ?></strong>
|
<p><strong><?= ApiMarkdown::process($type->shortDescription, $type, true) ?></strong></p>
|
||||||
<p><?= ApiMarkdown::process($type->description, $type) ?></p>
|
<?= ApiMarkdown::process($type->description, $type) ?>
|
||||||
|
|
||||||
|
<?= $this->render('seeAlso', ['object' => $type]) ?>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<a name="properties"></a>
|
<a name="properties"></a>
|
||||||
|
|||||||
Reference in New Issue
Block a user