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
79a14e7a
Commit
79a14e7a
authored
Jan 23, 2014
by
Carsten Brandt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
created apidoc generator online template for yiiframework.com
parent
35cd2bff
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
110 additions
and
4 deletions
+110
-4
TypeDoc.php
extensions/apidoc/models/TypeDoc.php
+1
-1
Renderer.php
extensions/apidoc/templates/html/Renderer.php
+8
-3
Renderer.php
extensions/apidoc/templates/online/Renderer.php
+69
-0
index.php
extensions/apidoc/templates/online/views/index.php
+32
-0
No files found.
extensions/apidoc/models/TypeDoc.php
View file @
79a14e7a
...
@@ -154,7 +154,7 @@ class TypeDoc extends BaseDoc
...
@@ -154,7 +154,7 @@ class TypeDoc extends BaseDoc
{
{
parent
::
__construct
(
$reflector
,
$config
);
parent
::
__construct
(
$reflector
,
$config
);
$this
->
namespace
=
StringHelper
::
base
name
(
$this
->
name
);
$this
->
namespace
=
StringHelper
::
dir
name
(
$this
->
name
);
if
(
$reflector
===
null
)
{
if
(
$reflector
===
null
)
{
return
;
return
;
...
...
extensions/apidoc/templates/html/Renderer.php
View file @
79a14e7a
...
@@ -96,7 +96,7 @@ abstract class Renderer extends BaseRenderer implements ViewContextInterface
...
@@ -96,7 +96,7 @@ abstract class Renderer extends BaseRenderer implements ViewContextInterface
$this
->
context
=
$context
;
$this
->
context
=
$context
;
$dir
=
Yii
::
getAlias
(
$this
->
targetDir
);
$dir
=
Yii
::
getAlias
(
$this
->
targetDir
);
if
(
!
is_dir
(
$dir
))
{
if
(
!
is_dir
(
$dir
))
{
mkdir
(
$dir
);
mkdir
(
$dir
,
0777
,
true
);
}
}
$types
=
array_merge
(
$context
->
classes
,
$context
->
interfaces
,
$context
->
traits
);
$types
=
array_merge
(
$context
->
classes
,
$context
->
interfaces
,
$context
->
traits
);
...
@@ -166,7 +166,7 @@ abstract class Renderer extends BaseRenderer implements ViewContextInterface
...
@@ -166,7 +166,7 @@ abstract class Renderer extends BaseRenderer implements ViewContextInterface
$links
[]
=
Html
::
a
(
$links
[]
=
Html
::
a
(
$type
->
name
,
$type
->
name
,
null
,
null
,
[
'href'
=>
$this
->
generate
FileName
(
$type
->
name
)]
[
'href'
=>
$this
->
generate
Link
(
$type
->
name
)]
)
.
$postfix
;
)
.
$postfix
;
}
}
}
}
...
@@ -191,7 +191,7 @@ abstract class Renderer extends BaseRenderer implements ViewContextInterface
...
@@ -191,7 +191,7 @@ abstract class Renderer extends BaseRenderer implements ViewContextInterface
if
((
$type
=
$this
->
context
->
getType
(
$subject
->
definedBy
))
===
null
)
{
if
((
$type
=
$this
->
context
->
getType
(
$subject
->
definedBy
))
===
null
)
{
return
$subject
->
name
;
return
$subject
->
name
;
}
else
{
}
else
{
$link
=
$this
->
generate
FileName
(
$type
->
name
);
$link
=
$this
->
generate
Link
(
$type
->
name
);
if
(
$subject
instanceof
MethodDoc
)
{
if
(
$subject
instanceof
MethodDoc
)
{
$link
.=
'#'
.
$subject
->
name
.
'()'
;
$link
.=
'#'
.
$subject
->
name
.
'()'
;
}
else
{
}
else
{
...
@@ -336,6 +336,11 @@ abstract class Renderer extends BaseRenderer implements ViewContextInterface
...
@@ -336,6 +336,11 @@ abstract class Renderer extends BaseRenderer implements ViewContextInterface
.
' )'
;
.
' )'
;
}
}
protected
function
generateLink
(
$typeName
)
{
return
$this
->
generateFileName
(
$typeName
);
}
protected
function
generateFileName
(
$typeName
)
protected
function
generateFileName
(
$typeName
)
{
{
return
strtolower
(
str_replace
(
'\\'
,
'_'
,
$typeName
))
.
'.html'
;
return
strtolower
(
str_replace
(
'\\'
,
'_'
,
$typeName
))
.
'.html'
;
...
...
extensions/apidoc/templates/online/Renderer.php
0 → 100644
View file @
79a14e7a
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace
yii\apidoc\templates\online
;
use
yii\apidoc\models\Context
;
use
yii\apidoc\models\TypeDoc
;
use
yii\console\Controller
;
use
Yii
;
use
yii\helpers\Console
;
use
yii\helpers\FileHelper
;
use
yii\helpers\StringHelper
;
/**
*
* @author Carsten Brandt <mail@cebe.cc>
* @since 2.0
*/
class
Renderer
extends
\yii\apidoc\templates\html\Renderer
{
public
$layout
=
false
;
//'@yii/apidoc/templates/offline/views/offline.php';
public
$indexView
=
'@yii/apidoc/templates/offline/views/index.php'
;
public
$pageTitle
=
'Yii Framework 2.0 API Documentation'
;
/**
* 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
render
(
$context
,
$controller
)
{
parent
::
render
(
$context
,
$controller
);
$dir
=
Yii
::
getAlias
(
$this
->
targetDir
);
$controller
->
stdout
(
"writing packages file..."
);
$packages
=
[];
$notNamespaced
=
[];
foreach
(
array_merge
(
$context
->
classes
,
$context
->
interfaces
,
$context
->
traits
)
as
$type
)
{
/** @var TypeDoc $type */
if
(
empty
(
$type
->
namespace
))
{
$notNamespaced
[]
=
str_replace
(
'\\'
,
'-'
,
$type
->
name
);
}
else
{
$packages
[
$type
->
namespace
][]
=
str_replace
(
'\\'
,
'-'
,
$type
->
name
);
}
}
ksort
(
$packages
);
$packages
=
array_merge
([
'Not namespaced'
=>
$notNamespaced
],
$packages
);
foreach
(
$packages
as
$name
=>
$classes
)
{
sort
(
$packages
[
$name
]);
}
file_put_contents
(
$dir
.
'/packages.txt'
,
serialize
(
$packages
));
$controller
->
stdout
(
'done.'
.
PHP_EOL
,
Console
::
FG_GREEN
);
}
protected
function
generateLink
(
$typeName
)
{
return
strtolower
(
str_replace
(
'\\'
,
'-'
,
$typeName
));
}
protected
function
generateFileName
(
$typeName
)
{
return
$this
->
generateLink
(
$typeName
)
.
'.html'
;
}
}
\ No newline at end of file
extensions/apidoc/templates/online/views/index.php
0 → 100644
View file @
79a14e7a
<?php
use
yii\apidoc\models\ClassDoc
;
use
yii\apidoc\models\InterfaceDoc
;
use
yii\apidoc\models\TraitDoc
;
/**
* @var ClassDoc[]|InterfaceDoc[]|TraitDoc[] $types
* @var yii\web\View $this
*/
?>
<h1>
Class Reference
</h1>
<table
class=
"summaryTable docIndex"
>
<colgroup>
<col
class=
"col-package"
/>
<col
class=
"col-class"
/>
<col
class=
"col-description"
/>
</colgroup>
<tr>
<th>
Class
</th>
<th>
Description
</th>
</tr>
<?php
ksort
(
$types
);
foreach
(
$types
as
$i
=>
$class
)
:
?>
<tr>
<td>
<?=
$this
->
context
->
typeLink
(
$class
,
$class
->
name
)
?>
</td>
<td>
<?=
\yii\apidoc\helpers\Markdown
::
process
(
$class
->
shortDescription
,
$class
)
?>
</td>
</tr>
<?php
endforeach
;
?>
</table>
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