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
59825446
Commit
59825446
authored
Jan 05, 2014
by
Carsten Brandt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
finished render command, added cli script
parent
81aea730
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
119 additions
and
59 deletions
+119
-59
apidoc
extensions/yii/apidoc/apidoc
+49
-0
apidoc.bat
extensions/yii/apidoc/apidoc.bat
+20
-0
RenderController.php
extensions/yii/apidoc/commands/RenderController.php
+44
-15
composer.json
extensions/yii/apidoc/composer.json
+2
-1
Context.php
extensions/yii/apidoc/models/Context.php
+4
-43
No files found.
extensions/yii/apidoc/apidoc
0 → 100755
View file @
59825446
#!/usr/bin/env php
<?php
/**
* Yii Framework 2.0 API documentation generator
*
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
defined
(
'YII_DEBUG'
)
or
define
(
'YII_DEBUG'
,
false
);
$composerAutoload
=
[
__DIR__
.
'/vendor/autoload.php'
,
// standalone with "composer install" run
__DIR__
.
'/../../../../autoload.php'
,
// script is installed as a composer binary
];
foreach
(
$composerAutoload
as
$autoload
)
{
if
(
file_exists
(
$autoload
))
{
require
(
$autoload
);
break
;
}
}
$yiiDirs
=
[
__DIR__
.
'/../../../framework'
,
// in yii2-dev repo
__DIR__
.
'/vendor/yiisoft/yii2'
,
// standalone with "composer install" run
__DIR__
.
'/../../../../yiisoft/yii2'
,
// script is installed as a composer binary
];
foreach
(
$yiiDirs
as
$dir
)
{
if
(
file_exists
(
$dir
.
'/yii/Yii.php'
))
{
require
(
$dir
.
'/yii/Yii.php'
);
break
;
}
}
if
(
!
class_exists
(
'Yii'
))
{
echo
"
\n
The Yii Framework 2.0 does not seem to be installed. Try running composer install.
\n\n
"
;
exit
(
1
);
}
Yii
::
setAlias
(
'@yii/apidoc'
,
__DIR__
);
$application
=
new
yii\console\Application
([
'id'
=>
'yii2-apidoc'
,
'basePath'
=>
__DIR__
,
'enableCoreCommands'
=>
false
,
'controllerNamespace'
=>
'yii\\apidoc\\commands'
,
'controllerPath'
=>
'@yii/apidoc/commands'
,
]);
$exitCode
=
$application
->
run
();
exit
(
$exitCode
);
extensions/yii/apidoc/apidoc.bat
0 → 100644
View file @
59825446
@echo off
rem -------------------------------------------------------------
rem Yii command line bootstrap script for Windows.
rem
rem @author Qiang Xue <qiang.xue@gmail.com>
rem @link http://www.yiiframework.com/
rem @copyright Copyright © 2012 Yii Software LLC
rem @license http://www.yiiframework.com/license/
rem -------------------------------------------------------------
@setlocal
set YII_PATH=%~dp0
if "%PHP_COMMAND%" == "" set PHP_COMMAND=php.exe
"%PHP_COMMAND%" "%YII_PATH%apidoc" %*
@endlocal
extensions/yii/apidoc/commands/
Phpdoc
Controller.php
→
extensions/yii/apidoc/commands/
Render
Controller.php
View file @
59825446
...
...
@@ -16,30 +16,59 @@ use yii\apidoc\models\Context;
use
Yii
;
/**
* Command to render API Documentation files
*
* @author Carsten Brandt <mail@cebe.cc>
* @since 2.0
*/
class
Phpdoc
Controller
extends
Controller
class
Render
Controller
extends
Controller
{
public
function
actionIndex
(
$targetDir
)
/**
* Renders API documentation files
* @param array $sourceDirs
* @param string $targetDir
* @return int
*/
public
function
actionIndex
(
array
$sourceDirs
,
$targetDir
)
{
echo
"hi
\n
"
;
$targetDir
=
Yii
::
getAlias
(
$targetDir
);
if
(
is_dir
(
$targetDir
)
&&
!
$this
->
confirm
(
'TargetDirectory already exists. Overwrite?'
))
{
return
2
;
}
if
(
!
is_dir
(
$targetDir
))
{
mkdir
(
$targetDir
);
}
// TODO determine files to analyze
$this
->
stdout
(
'Searching files to process... '
);
$files
=
$this
->
findFiles
(
YII_PATH
);
// $files = array_slice($files, 0, 42); // TODO remove this line
$files
=
[];
foreach
(
$sourceDirs
as
$source
)
{
foreach
(
$this
->
findFiles
(
$source
)
as
$fileName
)
{
$files
[
$fileName
]
=
$fileName
;
}
}
$this
->
stdout
(
'done.'
.
PHP_EOL
,
Console
::
FG_GREEN
);
$context
=
new
Context
();
$cacheFile
=
$targetDir
.
'/cache/'
.
md5
(
serialize
(
$files
))
.
'.tmp'
;
if
(
file_exists
(
$cacheFile
))
{
$this
->
stdout
(
'Loading processed data from cache... '
);
$context
=
unserialize
(
file_get_contents
(
$cacheFile
));
$this
->
stdout
(
'done.'
.
PHP_EOL
,
Console
::
FG_GREEN
);
$this
->
stdout
(
'Checking for updated files... '
);
foreach
(
$context
->
files
as
$file
=>
$sha
)
{
if
(
sha1_file
(
$file
)
===
$sha
)
{
unset
(
$files
[
$file
]);
}
}
$this
->
stdout
(
'done.'
.
PHP_EOL
,
Console
::
FG_GREEN
);
}
$fileCount
=
count
(
$files
);
$this
->
stdout
(
$fileCount
.
' file'
.
(
$fileCount
==
1
?
''
:
's'
)
.
' to update.'
.
PHP_EOL
);
Console
::
startProgress
(
0
,
$fileCount
,
'Processing files... '
,
false
);
$context
=
new
Context
();
$done
=
0
;
foreach
(
$files
as
$file
)
{
$context
->
addFile
(
$file
);
...
...
@@ -48,20 +77,22 @@ class PhpdocController extends Controller
Console
::
endProgress
(
true
);
$this
->
stdout
(
'done.'
.
PHP_EOL
,
Console
::
FG_GREEN
);
// save processed data to cache
if
(
!
is_dir
(
dirname
(
$cacheFile
)))
{
mkdir
(
dirname
(
$cacheFile
));
}
file_put_contents
(
$cacheFile
,
serialize
(
$context
));
$this
->
stdout
(
'Updating cross references and backlinks... '
);
$context
->
updateReferences
();
$this
->
stdout
(
'done.'
.
PHP_EOL
,
Console
::
FG_GREEN
);
// TODO LATER analyze for dead links and similar stuff
// TODO render models
// render models
$renderer
=
new
OfflineRenderer
();
$renderer
->
targetDir
=
$targetDir
;
$renderer
->
render
(
$context
,
$this
);
}
protected
function
findFiles
(
$path
,
$except
=
[])
{
$path
=
FileHelper
::
normalizePath
(
$path
);
...
...
@@ -84,5 +115,4 @@ class PhpdocController extends Controller
];
return
FileHelper
::
findFiles
(
$path
,
$options
);
}
}
\ No newline at end of file
extensions/yii/apidoc/composer.json
View file @
59825446
...
...
@@ -25,5 +25,6 @@
"autoload"
:
{
"psr-0"
:
{
"yii
\\
apidoc
\\
"
:
""
}
},
"target-dir"
:
"yii/apidoc"
"target-dir"
:
"yii/apidoc"
,
"bin"
:
[
"apidoc"
]
}
extensions/yii/apidoc/models/Context.php
View file @
59825446
...
...
@@ -47,10 +47,7 @@ class Context extends Component
public
function
addFile
(
$fileName
)
{
if
(
isset
(
$this
->
files
[
$fileName
]))
{
return
;
}
$this
->
files
[
$fileName
]
=
$fileName
;
$this
->
files
[
$fileName
]
=
sha1_file
(
$fileName
);
$reflection
=
new
FileReflector
(
$fileName
,
true
);
$reflection
->
process
();
...
...
@@ -58,55 +55,19 @@ class Context extends Component
foreach
(
$reflection
->
getClasses
()
as
$class
)
{
$class
=
new
ClassDoc
(
$class
);
$class
->
sourceFile
=
$fileName
;
$this
->
addClass
(
$class
)
;
$this
->
classes
[
$class
->
name
]
=
$class
;
}
foreach
(
$reflection
->
getInterfaces
()
as
$interface
)
{
$interface
=
new
InterfaceDoc
(
$interface
);
$interface
->
sourceFile
=
$fileName
;
$this
->
addInterface
(
$interface
)
;
$this
->
interfaces
[
$interface
->
name
]
=
$interface
;
}
foreach
(
$reflection
->
getTraits
()
as
$trait
)
{
$trait
=
new
TraitDoc
(
$trait
);
$trait
->
sourceFile
=
$fileName
;
$this
->
addTrait
(
$trait
);
}
}
/**
* @param ClassDoc $class
* @throws \yii\base\Exception when class is already part of this context
*/
public
function
addClass
(
$class
)
{
if
(
isset
(
$this
->
classes
[
$class
->
name
]))
{
throw
new
Exception
(
'Duplicate class definition: '
.
$class
->
name
.
' in file '
.
$class
->
sourceFile
.
'.'
);
}
$this
->
classes
[
$class
->
name
]
=
$class
;
}
/**
* @param InterfaceDoc $interface
* @throws \yii\base\Exception when interface is already part of this context
*/
public
function
addInterface
(
$interface
)
{
if
(
isset
(
$this
->
interfaces
[
$interface
->
name
]))
{
throw
new
Exception
(
'Duplicate interface definition: '
.
$interface
->
name
.
' in file '
.
$interface
->
sourceFile
);
}
$this
->
interfaces
[
$interface
->
name
]
=
$interface
;
}
/**
* @param TraitDoc $trait
* @throws \yii\base\Exception when trait is already part of this context
*/
public
function
addTrait
(
$trait
)
{
if
(
isset
(
$this
->
traits
[
$trait
->
name
]))
{
throw
new
Exception
(
'Duplicate trait definition: '
.
$trait
->
name
.
' in file '
.
$trait
->
sourceFile
);
}
$this
->
traits
[
$trait
->
name
]
=
$trait
;
}
}
public
function
updateReferences
()
{
...
...
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