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
7fa619fe
Commit
7fa619fe
authored
Jan 29, 2014
by
Carsten Brandt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added extensions to API docs
parent
3519c14e
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
111 additions
and
1 deletion
+111
-1
RenderController.php
extensions/apidoc/commands/RenderController.php
+1
-1
Renderer.php
extensions/apidoc/templates/bootstrap/Renderer.php
+97
-0
api.php
extensions/apidoc/templates/bootstrap/layouts/api.php
+1
-0
main.php
extensions/apidoc/templates/bootstrap/layouts/main.php
+8
-0
index.php
extensions/apidoc/templates/bootstrap/views/index.php
+4
-0
No files found.
extensions/apidoc/commands/RenderController.php
View file @
7fa619fe
...
...
@@ -128,7 +128,7 @@ class RenderController extends Controller
return
new
$rendererClass
();
}
protected
function
findFiles
(
$path
,
$except
=
[
'
/vendor/'
,
'/
tests/'
])
protected
function
findFiles
(
$path
,
$except
=
[
'
vendor/'
,
'
tests/'
])
{
$path
=
FileHelper
::
normalizePath
(
$path
);
$options
=
[
...
...
extensions/apidoc/templates/bootstrap/Renderer.php
View file @
7fa619fe
...
...
@@ -28,6 +28,103 @@ class Renderer extends \yii\apidoc\templates\html\Renderer
public
$guideUrl
;
public
$extensions
=
[
'apidoc'
,
'authclient'
,
'bootstrap'
,
'codeception'
,
'composer'
,
'debug'
,
'elasticsearch'
,
'faker'
,
'gii'
,
'imagine'
,
'jui'
,
'mongodb'
,
'redis'
,
'smarty'
,
'sphinx'
,
'swiftmailer'
,
'twig'
,
];
/**
* Renders a given [[Context]].
*
* @param Context $context the api documentation context to render.
* @param Controller $controller the apidoc controller instance. Can be used to control output.
*/
public
function
renderApi
(
$context
,
$controller
)
{
parent
::
renderApi
(
$context
,
$controller
);
$dir
=
Yii
::
getAlias
(
$this
->
targetDir
);
$types
=
array_merge
(
$context
->
classes
,
$context
->
interfaces
,
$context
->
traits
);
$controller
->
stdout
(
'generating extension index files...'
);
foreach
(
$this
->
extensions
as
$ext
)
{
$readme
=
@
file_get_contents
(
"https://raw.github.com/yiisoft/yii2-
$ext
/master/README.md"
);
$indexFileContent
=
$this
->
renderWithLayout
(
$this
->
indexView
,
[
'docContext'
=>
$context
,
'types'
=>
$this
->
filterTypes
(
$types
,
$ext
),
'readme'
=>
$readme
?:
null
,
]);
file_put_contents
(
$dir
.
"/ext_
{
$ext
}
_index.html"
,
$indexFileContent
);
}
$controller
->
stdout
(
'done.'
.
PHP_EOL
,
Console
::
FG_GREEN
);
}
public
function
getNavTypes
(
$type
,
$types
)
{
if
(
$type
===
null
)
{
return
$types
;
}
$extensions
=
$this
->
extensions
;
$navClasses
=
'app'
;
if
(
isset
(
$type
))
{
if
(
$type
->
name
==
'Yii'
)
{
$navClasses
=
'yii'
;
}
elseif
(
strncmp
(
$type
->
name
,
'yii\\'
,
4
)
==
0
)
{
$subName
=
substr
(
$type
->
name
,
4
);
if
((
$pos
=
strpos
(
$subName
,
'\\'
))
!==
false
)
{
$subNamespace
=
substr
(
$subName
,
0
,
$pos
);
if
(
in_array
(
$subNamespace
,
$extensions
))
{
$navClasses
=
$subNamespace
;
}
else
{
$navClasses
=
'yii'
;
}
}
}
}
return
$this
->
filterTypes
(
$types
,
$navClasses
);
}
protected
function
filterTypes
(
$types
,
$navClasses
)
{
switch
(
$navClasses
)
{
case
'app'
:
$types
=
array_filter
(
$types
,
function
(
$val
)
{
return
strncmp
(
$val
->
name
,
'yii\\'
,
4
)
!==
0
;
});
break
;
case
'yii'
:
$self
=
$this
;
$types
=
array_filter
(
$types
,
function
(
$val
)
use
(
$self
)
{
if
(
strlen
(
$val
->
name
)
<
5
)
{
return
false
;
}
$subName
=
substr
(
$val
->
name
,
4
,
strpos
(
$val
->
name
,
'\\'
,
5
)
-
4
);
return
strncmp
(
$val
->
name
,
'yii\\'
,
4
)
===
0
&&
!
in_array
(
$subName
,
$self
->
extensions
);
});
break
;
default
:
$types
=
array_filter
(
$types
,
function
(
$val
)
use
(
$navClasses
)
{
return
strncmp
(
$val
->
name
,
"yii
\\
$navClasses
\\
"
,
strlen
(
"yii
\\
$navClasses
\\
"
))
===
0
;
});
}
return
$types
;
}
/**
* Renders a given [[Context]].
*
...
...
extensions/apidoc/templates/bootstrap/layouts/api.php
View file @
7fa619fe
...
...
@@ -11,6 +11,7 @@ $this->beginContent('@yii/apidoc/templates/bootstrap/layouts/main.php'); ?>
<div
class=
"row"
>
<div
class=
"col-md-2"
>
<?php
$types
=
$this
->
context
->
getNavTypes
(
isset
(
$type
)
?
$type
:
null
,
$types
);
ksort
(
$types
);
$nav
=
[];
foreach
(
$types
as
$i
=>
$class
)
{
...
...
extensions/apidoc/templates/bootstrap/layouts/main.php
View file @
7fa619fe
...
...
@@ -37,9 +37,17 @@ $this->beginPage();
'padded'
=>
false
,
'view'
=>
$this
,
]);
$extItems
=
[];
foreach
(
$this
->
context
->
extensions
as
$ext
)
{
$extItems
[]
=
[
'label'
=>
$ext
,
'url'
=>
"./ext_
{
$ext
}
_index.html"
,
];
}
$nav
=
[
[
'label'
=>
'Class reference'
,
'url'
=>
'./index.html'
],
// ['label' => 'Application API', 'url' => '/site/about'],
[
'label'
=>
'Extensions'
,
'items'
=>
$extItems
],
];
if
(
$this
->
context
->
guideUrl
!==
null
)
{
$nav
[]
=
[
'label'
=>
'Guide'
,
'url'
=>
$this
->
context
->
guideUrl
.
'guide_index.html'
];
...
...
extensions/apidoc/templates/bootstrap/views/index.php
View file @
7fa619fe
...
...
@@ -8,6 +8,10 @@ use yii\apidoc\models\TraitDoc;
* @var yii\web\View $this
*/
if
(
isset
(
$readme
))
{
echo
\yii\apidoc\helpers\Markdown
::
process
(
$readme
);
}
?>
<h1>
Class Reference
</h1>
<table
class=
"summaryTable docIndex table table-bordered table-striped table-hover"
>
...
...
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