Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
85f49e0c
Commit
85f49e0c
authored
May 25, 2014
by
Carsten Brandt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed apidoc short description
fixes #2797
parent
e3ee1b07
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
27 additions
and
17 deletions
+27
-17
BaseDoc.php
extensions/apidoc/models/BaseDoc.php
+16
-0
Context.php
extensions/apidoc/models/Context.php
+2
-4
EventDoc.php
extensions/apidoc/models/EventDoc.php
+1
-5
PropertyDoc.php
extensions/apidoc/models/PropertyDoc.php
+1
-5
seeAlso.php
extensions/apidoc/templates/html/views/seeAlso.php
+3
-1
type.php
extensions/apidoc/templates/html/views/type.php
+4
-2
No files found.
extensions/apidoc/models/BaseDoc.php
View file @
85f49e0c
...
...
@@ -127,4 +127,20 @@ class BaseDoc extends Object
// $lines = file(YII_PATH . $this->sourcePath);
// 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
;
}
}
}
extensions/apidoc/models/Context.php
View file @
85f49e0c
...
...
@@ -289,8 +289,7 @@ class Context extends Component
'isStatic'
=>
false
,
'type'
=>
$method
->
returnType
,
'types'
=>
$method
->
returnTypes
,
'shortDescription'
=>
((
$pos
=
strpos
(
$method
->
return
,
'.'
))
!==
false
)
?
substr
(
$method
->
return
,
0
,
$pos
)
:
$method
->
return
,
'shortDescription'
=>
BaseDoc
::
extractFirstSentence
(
$method
->
return
),
'description'
=>
$method
->
return
,
'getter'
=>
$method
// TODO set default value
...
...
@@ -319,8 +318,7 @@ class Context extends Component
'isStatic'
=>
false
,
'type'
=>
$param
->
type
,
'types'
=>
$param
->
types
,
'shortDescription'
=>
((
$pos
=
strpos
(
$param
->
description
,
'.'
))
!==
false
)
?
substr
(
$param
->
description
,
0
,
$pos
)
:
$param
->
description
,
'shortDescription'
=>
BaseDoc
::
extractFirstSentence
(
$param
->
description
),
'description'
=>
$param
->
description
,
'setter'
=>
$method
]);
...
...
extensions/apidoc/models/EventDoc.php
View file @
85f49e0c
...
...
@@ -39,11 +39,7 @@ class EventDoc extends ConstDoc
$this
->
type
=
$eventTag
->
getType
();
$this
->
types
=
$eventTag
->
getTypes
();
$this
->
description
=
ucfirst
(
$eventTag
->
getDescription
());
if
((
$pos
=
strpos
(
$this
->
description
,
'.'
))
!==
false
)
{
$this
->
shortDescription
=
substr
(
$this
->
description
,
0
,
$pos
);
}
else
{
$this
->
shortDescription
=
$this
->
description
;
}
$this
->
shortDescription
=
BaseDoc
::
extractFirstSentence
(
$this
->
description
);
unset
(
$this
->
tags
[
$i
]);
}
}
...
...
extensions/apidoc/models/PropertyDoc.php
View file @
85f49e0c
...
...
@@ -72,11 +72,7 @@ class PropertyDoc extends BaseDoc
$this
->
type
=
$tag
->
getType
();
$this
->
types
=
$tag
->
getTypes
();
$this
->
description
=
ucfirst
(
$tag
->
getDescription
());
if
((
$pos
=
strpos
(
$this
->
description
,
'.'
))
!==
false
)
{
$this
->
shortDescription
=
substr
(
$this
->
description
,
0
,
$pos
+
1
);
}
else
{
$this
->
shortDescription
=
$this
->
description
;
}
$this
->
shortDescription
=
BaseDoc
::
extractFirstSentence
(
$this
->
description
);
}
}
if
(
empty
(
$this
->
shortDescription
)
&&
$context
!==
null
&&
!
$hasInheritdoc
)
{
...
...
extensions/apidoc/templates/html/views/seeAlso.php
View file @
85f49e0c
...
...
@@ -5,6 +5,8 @@
* @var yii\web\View $this
*/
$type
=
$object
instanceof
\yii\apidoc\models\TypeDoc
?
$object
:
$object
->
definedBy
;
$see
=
[];
foreach
(
$object
->
tags
as
$tag
)
{
/** @var $tag phpDocumentor\Reflection\DocBlock\Tag\SeeTag */
...
...
@@ -13,7 +15,7 @@ foreach ($object->tags as $tag) {
if
(
strpos
(
$ref
,
'://'
)
===
false
)
{
$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
))
{
...
...
extensions/apidoc/templates/html/views/type.php
View file @
85f49e0c
...
...
@@ -80,8 +80,10 @@ $renderer = $this->context;
</table>
<div
id=
"classDescription"
>
<strong>
<?=
ApiMarkdown
::
process
(
$type
->
shortDescription
,
$type
,
true
)
?>
</strong>
<p>
<?=
ApiMarkdown
::
process
(
$type
->
description
,
$type
)
?>
</p>
<p><strong>
<?=
ApiMarkdown
::
process
(
$type
->
shortDescription
,
$type
,
true
)
?>
</strong></p>
<?=
ApiMarkdown
::
process
(
$type
->
description
,
$type
)
?>
<?=
$this
->
render
(
'seeAlso'
,
[
'object'
=>
$type
])
?>
</div>
<a
name=
"properties"
></a>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment