|
1
|
|
|
<?php |
|
2
|
|
|
declare(strict_types=1); |
|
3
|
|
|
|
|
4
|
|
|
/** |
|
5
|
|
|
* This file is part of phpDocumentor. |
|
6
|
|
|
* |
|
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
8
|
|
|
* file that was distributed with this source code. |
|
9
|
|
|
* |
|
10
|
|
|
* @author Mike van Riel <[email protected]> |
|
11
|
|
|
* @copyright 2010-2018 Mike van Riel / Naenius (http://www.naenius.com) |
|
12
|
|
|
* @license http://www.opensource.org/licenses/mit-license.php MIT |
|
13
|
|
|
* @link http://phpdoc.org |
|
14
|
|
|
*/ |
|
15
|
|
|
|
|
16
|
|
|
namespace phpDocumentor\Console\Command\Project; |
|
17
|
|
|
|
|
18
|
|
|
use League\Pipeline\PipelineInterface; |
|
19
|
|
|
use Symfony\Component\Console\Command\Command; |
|
20
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
|
21
|
|
|
use Symfony\Component\Console\Input\InputOption; |
|
22
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* Parses the given source code and creates a structure file. |
|
26
|
|
|
* |
|
27
|
|
|
* The parse task uses the source files defined either by -f or -d options and |
|
28
|
|
|
* generates a structure file (structure.xml) at the target location (which is |
|
29
|
|
|
* the folder 'output' unless the option -t is provided). |
|
30
|
|
|
*/ |
|
31
|
|
|
final class ParseCommand extends Command |
|
32
|
|
|
{ |
|
33
|
|
|
/** @var PipelineInterface */ |
|
34
|
|
|
private $pipeline; |
|
35
|
|
|
|
|
36
|
|
|
public function __construct(PipelineInterface $pipeline) |
|
37
|
|
|
{ |
|
38
|
|
|
$this->pipeline = $pipeline; |
|
39
|
|
|
|
|
40
|
|
|
parent::__construct('project:parse'); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* Initializes this command and sets the name, description, options and arguments. |
|
45
|
|
|
*/ |
|
46
|
1 |
|
protected function configure(): void |
|
47
|
|
|
{ |
|
48
|
1 |
|
$this->setAliases(['parse']) |
|
49
|
1 |
|
->setDescription('Creates a structure file from your source code') |
|
50
|
1 |
|
->setHelp(<<<HELP |
|
51
|
1 |
|
The parse task uses the source files defined either by -f or -d options and |
|
52
|
|
|
generates cache files at the target location. |
|
53
|
|
|
HELP |
|
54
|
|
|
) |
|
55
|
1 |
|
->addOption( |
|
56
|
1 |
|
'filename', |
|
57
|
1 |
|
'f', |
|
58
|
1 |
|
InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, |
|
59
|
1 |
|
'Comma-separated list of files to parse. The wildcards ? and * are supported' |
|
60
|
|
|
) |
|
61
|
1 |
|
->addOption( |
|
62
|
1 |
|
'directory', |
|
63
|
1 |
|
'd', |
|
64
|
1 |
|
InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, |
|
65
|
1 |
|
'Comma-separated list of directories to (recursively) parse' |
|
66
|
|
|
) |
|
67
|
1 |
|
->addOption( |
|
68
|
1 |
|
'target', |
|
69
|
1 |
|
't', |
|
70
|
1 |
|
InputOption::VALUE_OPTIONAL, |
|
71
|
1 |
|
'Path where to store the cache (optional)' |
|
72
|
|
|
) |
|
73
|
1 |
|
->addOption( |
|
74
|
1 |
|
'encoding', |
|
75
|
1 |
|
null, |
|
76
|
1 |
|
InputOption::VALUE_OPTIONAL, |
|
77
|
1 |
|
'Encoding to be used to interpret source files with' |
|
78
|
|
|
) |
|
79
|
1 |
|
->addOption( |
|
80
|
1 |
|
'extensions', |
|
81
|
1 |
|
null, |
|
82
|
1 |
|
InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, |
|
83
|
1 |
|
'Comma-separated list of extensions to parse, defaults to php, php3 and phtml' |
|
84
|
|
|
) |
|
85
|
1 |
|
->addOption( |
|
86
|
1 |
|
'ignore', |
|
87
|
1 |
|
'i', |
|
88
|
1 |
|
InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, |
|
89
|
|
|
'Comma-separated list of file(s) and directories that will be ignored. Wildcards * and ? ' |
|
90
|
1 |
|
. 'are supported' |
|
91
|
|
|
) |
|
92
|
1 |
|
->addOption( |
|
93
|
1 |
|
'ignore-tags', |
|
94
|
1 |
|
null, |
|
95
|
1 |
|
InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, |
|
96
|
|
|
'Comma-separated list of tags that will be ignored, defaults to none. package, subpackage ' |
|
97
|
1 |
|
. 'and ignore may not be ignored.' |
|
98
|
|
|
) |
|
99
|
1 |
|
->addOption( |
|
100
|
1 |
|
'hidden', |
|
101
|
1 |
|
null, |
|
102
|
1 |
|
InputOption::VALUE_NONE, |
|
103
|
|
|
'Use this option to tell phpDocumentor to parse files and directories that begin with a ' |
|
104
|
1 |
|
. 'period (.), by default these are ignored' |
|
105
|
|
|
) |
|
106
|
1 |
|
->addOption( |
|
107
|
1 |
|
'ignore-symlinks', |
|
108
|
1 |
|
null, |
|
109
|
1 |
|
InputOption::VALUE_NONE, |
|
110
|
1 |
|
'Ignore symlinks to other files or directories, default is on' |
|
111
|
|
|
) |
|
112
|
1 |
|
->addOption( |
|
113
|
1 |
|
'markers', |
|
114
|
1 |
|
'm', |
|
115
|
1 |
|
InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, |
|
116
|
1 |
|
'Comma-separated list of markers/tags to filter', |
|
117
|
1 |
|
['TODO', 'FIXME'] |
|
118
|
|
|
) |
|
119
|
1 |
|
->addOption( |
|
120
|
1 |
|
'title', |
|
121
|
1 |
|
null, |
|
122
|
1 |
|
InputOption::VALUE_OPTIONAL, |
|
123
|
1 |
|
'Sets the title for this project; default is the phpDocumentor logo' |
|
124
|
|
|
) |
|
125
|
1 |
|
->addOption( |
|
126
|
1 |
|
'force', |
|
127
|
1 |
|
null, |
|
128
|
1 |
|
InputOption::VALUE_NONE, |
|
129
|
1 |
|
'Forces a full build of the documentation, does not increment existing documentation' |
|
130
|
|
|
) |
|
131
|
1 |
|
->addOption( |
|
132
|
1 |
|
'validate', |
|
133
|
1 |
|
null, |
|
134
|
1 |
|
InputOption::VALUE_NONE, |
|
135
|
1 |
|
'Validates every processed file using PHP Lint, costs a lot of performance' |
|
136
|
|
|
) |
|
137
|
1 |
|
->addOption( |
|
138
|
1 |
|
'visibility', |
|
139
|
1 |
|
null, |
|
140
|
1 |
|
InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, |
|
141
|
|
|
'Specifies the parse visibility that should be displayed in the documentation (comma ' |
|
142
|
1 |
|
. 'separated e.g. "public,protected")' |
|
143
|
|
|
) |
|
144
|
1 |
|
->addOption( |
|
145
|
1 |
|
'sourcecode', |
|
146
|
1 |
|
null, |
|
147
|
1 |
|
InputOption::VALUE_NONE, |
|
148
|
1 |
|
'Whether to include syntax highlighted source code' |
|
149
|
|
|
) |
|
150
|
1 |
|
->addOption( |
|
151
|
1 |
|
'parseprivate', |
|
152
|
1 |
|
null, |
|
153
|
1 |
|
InputOption::VALUE_NONE, |
|
154
|
1 |
|
'Whether to parse DocBlocks marked with @internal tag' |
|
155
|
|
|
) |
|
156
|
1 |
|
->addOption( |
|
157
|
1 |
|
'defaultpackagename', |
|
158
|
1 |
|
null, |
|
159
|
1 |
|
InputOption::VALUE_OPTIONAL, |
|
160
|
1 |
|
'Name to use for the default package.', |
|
161
|
1 |
|
'Default' |
|
162
|
|
|
); |
|
163
|
|
|
|
|
164
|
1 |
|
parent::configure(); |
|
165
|
1 |
|
} |
|
166
|
|
|
|
|
167
|
|
|
/** |
|
168
|
|
|
* Executes the business logic involved with this command. |
|
169
|
|
|
*/ |
|
170
|
1 |
|
protected function execute(InputInterface $input, OutputInterface $output): int |
|
171
|
|
|
{ |
|
172
|
1 |
|
$pipeLine = $this->pipeline; |
|
173
|
1 |
|
$pipeLine($input->getOptions()); |
|
174
|
|
|
|
|
175
|
1 |
|
return 0; |
|
176
|
|
|
} |
|
177
|
|
|
} |
|
178
|
|
|
|