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
31a1eca5
Commit
31a1eca5
authored
Mar 07, 2014
by
Carsten Brandt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add source code links to api docs
parent
6df4802e
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
51 additions
and
17 deletions
+51
-17
BaseDoc.php
extensions/apidoc/models/BaseDoc.php
+0
-9
TypeDoc.php
extensions/apidoc/models/TypeDoc.php
+1
-1
ApiRenderer.php
extensions/apidoc/templates/bootstrap/ApiRenderer.php
+26
-0
RendererTrait.php
extensions/apidoc/templates/bootstrap/RendererTrait.php
+8
-3
ApiRenderer.php
extensions/apidoc/templates/html/ApiRenderer.php
+5
-0
methodDetails.php
extensions/apidoc/templates/html/views/methodDetails.php
+5
-0
type.php
extensions/apidoc/templates/html/views/type.php
+6
-4
No files found.
extensions/apidoc/models/BaseDoc.php
View file @
31a1eca5
...
@@ -95,7 +95,6 @@ class BaseDoc extends Object
...
@@ -95,7 +95,6 @@ class BaseDoc extends Object
}
}
}
}
// TODO
// TODO
public
function
loadSource
(
$reflection
)
public
function
loadSource
(
$reflection
)
{
{
...
@@ -104,14 +103,6 @@ class BaseDoc extends Object
...
@@ -104,14 +103,6 @@ class BaseDoc extends Object
$this
->
endLine
=
$reflection
->
getEndLine
();
$this
->
endLine
=
$reflection
->
getEndLine
();
}
}
public
function
getSourceUrl
(
$baseUrl
,
$line
=
null
)
{
if
(
$line
===
null
)
return
$baseUrl
.
$this
->
sourcePath
;
else
return
$baseUrl
.
$this
->
sourcePath
.
'#'
.
$line
;
}
public
function
getSourceCode
()
public
function
getSourceCode
()
{
{
$lines
=
file
(
YII_PATH
.
$this
->
sourcePath
);
$lines
=
file
(
YII_PATH
.
$this
->
sourcePath
);
...
...
extensions/apidoc/models/TypeDoc.php
View file @
31a1eca5
...
@@ -161,7 +161,7 @@ class TypeDoc extends BaseDoc
...
@@ -161,7 +161,7 @@ class TypeDoc extends BaseDoc
{
{
parent
::
__construct
(
$reflector
,
$context
,
$config
);
parent
::
__construct
(
$reflector
,
$context
,
$config
);
$this
->
namespace
=
StringHelper
::
dirname
(
$this
->
name
);
$this
->
namespace
=
trim
(
StringHelper
::
dirname
(
$this
->
name
),
'\\'
);
if
(
$reflector
===
null
)
{
if
(
$reflector
===
null
)
{
return
;
return
;
...
...
extensions/apidoc/templates/bootstrap/ApiRenderer.php
View file @
31a1eca5
...
@@ -88,4 +88,29 @@ class ApiRenderer extends \yii\apidoc\templates\html\ApiRenderer
...
@@ -88,4 +88,29 @@ class ApiRenderer extends \yii\apidoc\templates\html\ApiRenderer
$this
->
controller
->
stdout
(
'done.'
.
PHP_EOL
,
Console
::
FG_GREEN
);
$this
->
controller
->
stdout
(
'done.'
.
PHP_EOL
,
Console
::
FG_GREEN
);
}
}
}
}
public
function
getSourceUrl
(
$type
,
$line
=
null
)
{
if
(
is_string
(
$type
))
{
$type
=
$this
->
apiContext
->
getType
(
$type
);
}
$baseUrl
=
'https://github.com/yiisoft/yii2/blob/master'
;
switch
(
$this
->
getTypeCategory
(
$type
))
{
case
'yii'
:
$url
=
'/framework/'
.
str_replace
(
'\\'
,
'/'
,
substr
(
$type
->
name
,
4
))
.
'.php'
;
break
;
case
'app'
:
return
null
;
default
:
$url
=
'/extensions/'
.
str_replace
(
'\\'
,
'/'
,
substr
(
$type
->
name
,
4
))
.
'.php'
;
break
;
}
if
(
$line
===
null
)
return
$baseUrl
.
$url
;
else
return
$baseUrl
.
$url
.
'#L'
.
$line
;
}
}
}
\ No newline at end of file
extensions/apidoc/templates/bootstrap/RendererTrait.php
View file @
31a1eca5
...
@@ -33,6 +33,11 @@ trait RendererTrait
...
@@ -33,6 +33,11 @@ trait RendererTrait
if
(
$type
===
null
)
{
if
(
$type
===
null
)
{
return
$types
;
return
$types
;
}
}
return
$this
->
filterTypes
(
$types
,
$this
->
getTypeCategory
(
$type
));
}
protected
function
getTypeCategory
(
$type
)
{
$extensions
=
$this
->
extensions
;
$extensions
=
$this
->
extensions
;
$navClasses
=
'app'
;
$navClasses
=
'app'
;
if
(
isset
(
$type
))
{
if
(
isset
(
$type
))
{
...
@@ -49,7 +54,7 @@ trait RendererTrait
...
@@ -49,7 +54,7 @@ trait RendererTrait
}
}
}
}
}
}
return
$
this
->
filterTypes
(
$types
,
$navClasses
)
;
return
$
navClasses
;
}
}
protected
function
filterTypes
(
$types
,
$navClasses
)
protected
function
filterTypes
(
$types
,
$navClasses
)
...
@@ -81,4 +86,4 @@ trait RendererTrait
...
@@ -81,4 +86,4 @@ trait RendererTrait
}
}
return
$types
;
return
$types
;
}
}
}
}
\ No newline at end of file
\ No newline at end of file
extensions/apidoc/templates/html/ApiRenderer.php
View file @
31a1eca5
...
@@ -279,4 +279,9 @@ class ApiRenderer extends BaseApiRenderer implements ViewContextInterface
...
@@ -279,4 +279,9 @@ class ApiRenderer extends BaseApiRenderer implements ViewContextInterface
{
{
return
Html
::
a
(
$text
,
null
,
[
'href'
=>
$href
]);
return
Html
::
a
(
$text
,
null
,
[
'href'
=>
$href
]);
}
}
public
function
getSourceUrl
(
$type
)
{
return
null
;
}
}
}
extensions/apidoc/templates/html/views/methodDetails.php
View file @
31a1eca5
...
@@ -61,6 +61,11 @@ ArrayHelper::multisort($methods, 'name');
...
@@ -61,6 +61,11 @@ ArrayHelper::multisort($methods, 'name');
</tr>
</tr>
<?php
endforeach
;
?>
<?php
endforeach
;
?>
<?php
endif
;
?>
<?php
endif
;
?>
<?php
if
((
$sourceUrl
=
$renderer
->
getSourceUrl
(
$method
->
definedBy
,
$method
->
startLine
))
!==
null
)
:
?>
<tr>
<td
colspan=
"3"
>
Source Code:
<a
href=
"
<?=
$sourceUrl
?>
"
>
<?=
$sourceUrl
?>
</a></td>
</tr>
<?php
endif
;
?>
</table>
</table>
<!-- -->
<?php
//$this->renderPartial('sourceCode',array('object'=>$method)); ?>
<!-- -->
<?php
//$this->renderPartial('sourceCode',array('object'=>$method)); ?>
...
...
extensions/apidoc/templates/html/views/type.php
View file @
31a1eca5
...
@@ -70,10 +70,12 @@ $renderer = $this->context;
...
@@ -70,10 +70,12 @@ $renderer = $this->context;
<?php
if
(
!
empty
(
$type
->
since
))
:
?>
<?php
if
(
!
empty
(
$type
->
since
))
:
?>
<tr><th>
Available since version
</th><td>
<?=
$type
->
since
?>
</td></tr>
<tr><th>
Available since version
</th><td>
<?=
$type
->
since
?>
</td></tr>
<?php
endif
;
?>
<?php
endif
;
?>
<tr>
<?php
if
((
$sourceUrl
=
$renderer
->
getSourceUrl
(
$type
))
!==
null
)
:
?>
<th>
Source Code
</th>
<tr>
<td>
<?php
// TODO echo $this->renderSourceLink($type->sourcePath) ?></td>
<th>
Source Code
</th>
</
tr
>
<td><a
href=
"
<?=
$sourceUrl
?>
"
>
<?=
$sourceUrl
?>
</a></td>
</tr>
<?php
endif
;
?>
</table>
</table>
<div
id=
"classDescription"
>
<div
id=
"classDescription"
>
...
...
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