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
5e356acb
Commit
5e356acb
authored
Mar 07, 2014
by
Carsten Brandt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
exclude file support for apidocs
issue #1797
parent
bbea1ab1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
10 deletions
+31
-10
ApiController.php
extensions/apidoc/commands/ApiController.php
+10
-3
GuideController.php
extensions/apidoc/commands/GuideController.php
+7
-2
BaseController.php
extensions/apidoc/components/BaseController.php
+14
-5
No files found.
extensions/apidoc/commands/ApiController.php
View file @
5e356acb
...
@@ -62,7 +62,9 @@ class ApiController extends BaseController
...
@@ -62,7 +62,9 @@ class ApiController extends BaseController
}
}
// search for files to process
// search for files to process
$files
=
$this
->
searchFiles
(
$sourceDirs
);
if
((
$files
=
$this
->
searchFiles
(
$sourceDirs
))
===
false
)
{
return
1
;
}
// load context from cache
// load context from cache
$context
=
$this
->
loadContext
(
$targetDir
);
$context
=
$this
->
loadContext
(
$targetDir
);
...
@@ -71,7 +73,9 @@ class ApiController extends BaseController
...
@@ -71,7 +73,9 @@ class ApiController extends BaseController
if
(
!
file_exists
(
$file
))
{
if
(
!
file_exists
(
$file
))
{
$this
->
stdout
(
'At least one file has been removed. Rebuilding the context...'
);
$this
->
stdout
(
'At least one file has been removed. Rebuilding the context...'
);
$context
=
new
Context
();
$context
=
new
Context
();
$files
=
$this
->
searchFiles
(
$sourceDirs
);
if
((
$files
=
$this
->
searchFiles
(
$sourceDirs
))
===
false
)
{
return
1
;
}
break
;
break
;
}
}
if
(
sha1_file
(
$file
)
===
$sha
)
{
if
(
sha1_file
(
$file
)
===
$sha
)
{
...
@@ -108,8 +112,11 @@ class ApiController extends BaseController
...
@@ -108,8 +112,11 @@ class ApiController extends BaseController
}
}
}
}
protected
function
findFiles
(
$path
,
$except
=
[
'vendor/'
,
'tests/'
])
protected
function
findFiles
(
$path
,
$except
=
[])
{
{
if
(
empty
(
$except
))
{
$except
=
[
'vendor/'
,
'tests/'
];
}
$path
=
FileHelper
::
normalizePath
(
$path
);
$path
=
FileHelper
::
normalizePath
(
$path
);
$options
=
[
$options
=
[
'filter'
=>
function
(
$path
)
{
'filter'
=>
function
(
$path
)
{
...
...
extensions/apidoc/commands/GuideController.php
View file @
5e356acb
...
@@ -56,7 +56,9 @@ class GuideController extends BaseController
...
@@ -56,7 +56,9 @@ class GuideController extends BaseController
$this
->
updateContext
(
$renderer
->
apiContext
);
$this
->
updateContext
(
$renderer
->
apiContext
);
// search for files to process
// search for files to process
$files
=
$this
->
searchFiles
(
$sourceDirs
);
if
((
$files
=
$this
->
searchFiles
(
$sourceDirs
))
===
false
)
{
return
1
;
}
$renderer
->
controller
=
$this
;
$renderer
->
controller
=
$this
;
$renderer
->
render
(
$files
,
$targetDir
);
$renderer
->
render
(
$files
,
$targetDir
);
...
@@ -75,8 +77,11 @@ class GuideController extends BaseController
...
@@ -75,8 +77,11 @@ class GuideController extends BaseController
file_put_contents
(
$targetDir
.
'/guide-references.txt'
,
implode
(
"
\n
"
,
$references
));
file_put_contents
(
$targetDir
.
'/guide-references.txt'
,
implode
(
"
\n
"
,
$references
));
}
}
protected
function
findFiles
(
$path
,
$except
=
[
'README.md'
])
protected
function
findFiles
(
$path
,
$except
=
[])
{
{
if
(
empty
(
$except
))
{
$except
=
[
'README.md'
];
}
$path
=
FileHelper
::
normalizePath
(
$path
);
$path
=
FileHelper
::
normalizePath
(
$path
);
$options
=
[
$options
=
[
'only'
=>
[
'*.md'
],
'only'
=>
[
'*.md'
],
...
...
extensions/apidoc/components/BaseController.php
View file @
5e356acb
...
@@ -26,9 +26,9 @@ abstract class BaseController extends Controller
...
@@ -26,9 +26,9 @@ abstract class BaseController extends Controller
*/
*/
public
$template
=
'bootstrap'
;
public
$template
=
'bootstrap'
;
/**
/**
* @var string|array files to exclude.
NOT IMPLEMENTED YET
* @var string|array files to exclude.
*/
*/
public
$exclude
;
// TODO implement
public
$exclude
;
protected
function
normalizeTargetDir
(
$target
)
protected
function
normalizeTargetDir
(
$target
)
...
@@ -53,8 +53,17 @@ abstract class BaseController extends Controller
...
@@ -53,8 +53,17 @@ abstract class BaseController extends Controller
{
{
$this
->
stdout
(
'Searching files to process... '
);
$this
->
stdout
(
'Searching files to process... '
);
$files
=
[];
$files
=
[];
if
(
is_array
(
$this
->
exclude
))
{
$exclude
=
$this
->
exclude
;
}
elseif
(
is_string
(
$this
->
exclude
))
{
$exclude
=
explode
(
','
,
$this
->
exclude
);
}
else
{
$exclude
=
[];
}
foreach
(
$sourceDirs
as
$source
)
{
foreach
(
$sourceDirs
as
$source
)
{
foreach
(
$this
->
findFiles
(
$source
)
as
$fileName
)
{
foreach
(
$this
->
findFiles
(
$source
,
$exclude
)
as
$fileName
)
{
$files
[
$fileName
]
=
$fileName
;
$files
[
$fileName
]
=
$fileName
;
}
}
}
}
...
@@ -62,12 +71,12 @@ abstract class BaseController extends Controller
...
@@ -62,12 +71,12 @@ abstract class BaseController extends Controller
if
(
empty
(
$files
))
{
if
(
empty
(
$files
))
{
$this
->
stderr
(
'Error: No files found to process.'
.
PHP_EOL
);
$this
->
stderr
(
'Error: No files found to process.'
.
PHP_EOL
);
return
1
;
return
false
;
}
}
return
$files
;
return
$files
;
}
}
protected
abstract
function
findFiles
(
$dir
);
protected
abstract
function
findFiles
(
$dir
,
$except
=
[]
);
protected
function
loadContext
(
$location
)
protected
function
loadContext
(
$location
)
...
...
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