1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* phpDocumentor |
4
|
|
|
* |
5
|
|
|
* PHP Version 5.3 |
6
|
|
|
* |
7
|
|
|
* @copyright 2010-2018 Mike van Riel / Naenius (http://www.naenius.com) |
8
|
|
|
* @license http://www.opensource.org/licenses/mit-license.php MIT |
9
|
|
|
* @link http://phpdoc.org |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace phpDocumentor\Application\Console\Command\Project; |
13
|
|
|
|
14
|
|
|
use League\Pipeline\Pipeline; |
15
|
|
|
use phpDocumentor\Application\Console\Command\Command; |
16
|
|
|
use phpDocumentor\Application\Stage\Configure; |
17
|
|
|
use phpDocumentor\Descriptor\ProjectDescriptorBuilder; |
18
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
19
|
|
|
use Symfony\Component\Console\Input\InputOption; |
20
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* Parse and transform the given directory (-d|-f) to the given location (-t). |
24
|
|
|
* |
25
|
|
|
* phpDocumentor creates documentation from PHP source files. The simplest way |
26
|
|
|
* to use it is: |
27
|
|
|
* |
28
|
|
|
* $ phpdoc run -d <directory to parse> -t <output directory> |
29
|
|
|
* |
30
|
|
|
* This will parse every file ending with .php, .php3 and .phtml in <directory |
31
|
|
|
* to parse> and then output a HTML site containing easily readable documentation |
32
|
|
|
* in <output directory>. |
33
|
|
|
* |
34
|
|
|
* phpDocumentor will try to look for a phpdoc.dist.xml or phpdoc.xml file in your |
35
|
|
|
* current working directory and use that to override the default settings if |
36
|
|
|
* present. In the configuration file can you specify the same settings (and |
37
|
|
|
* more) as the command line provides. |
38
|
|
|
*/ |
39
|
|
|
class RunCommand extends Command |
40
|
|
|
{ |
41
|
|
|
/** |
42
|
|
|
* @var ProjectDescriptorBuilder |
43
|
|
|
*/ |
44
|
|
|
private $projectDescriptorBuilder; |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @var Pipeline |
48
|
|
|
*/ |
49
|
|
|
private $pipeline; |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* RunCommand constructor. |
53
|
|
|
*/ |
54
|
|
|
public function __construct(ProjectDescriptorBuilder $projectDescriptorBuilder, Pipeline $pipeline) |
55
|
|
|
{ |
56
|
|
|
parent::__construct('project:run'); |
57
|
|
|
$this->projectDescriptorBuilder = $projectDescriptorBuilder; |
58
|
|
|
$this->pipeline = $pipeline; |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* Initializes this command and sets the name, description, options and |
63
|
|
|
* arguments. |
64
|
|
|
*/ |
65
|
|
|
protected function configure() |
66
|
|
|
{ |
67
|
|
|
$this->setName('project:run') |
68
|
|
|
->setAliases(['run']) |
69
|
|
|
->setDescription( |
70
|
|
|
'Parses and transforms the given files to a specified location' |
71
|
|
|
) |
72
|
|
|
->setHelp( |
73
|
|
|
<<<HELP |
74
|
|
|
phpDocumentor creates documentation from PHP source files. The simplest way |
75
|
|
|
to use it is: |
76
|
|
|
|
77
|
|
|
<info>$ phpdoc run -d [directory to parse] -t [output directory]</info> |
78
|
|
|
|
79
|
|
|
This will parse every file ending with .php, .php3 and .phtml in <directory |
80
|
|
|
to parse> and then output a HTML site containing easily readable documentation |
81
|
|
|
in <output directory>. |
82
|
|
|
|
83
|
|
|
phpDocumentor will try to look for a phpdoc.dist.xml or phpdoc.xml file in your |
84
|
|
|
current working directory and use that to override the default settings if |
85
|
|
|
present. In the configuration file can you specify the same settings (and |
86
|
|
|
more) as the command line provides. |
87
|
|
|
|
88
|
|
|
<comment>Other commands</comment> |
89
|
|
|
In addition to this command phpDocumentor also supports additional commands: |
90
|
|
|
|
91
|
|
|
<comment>Available commands:</comment> |
92
|
|
|
<info> help |
93
|
|
|
list |
94
|
|
|
parse |
95
|
|
|
run |
96
|
|
|
transform |
97
|
|
|
<comment>project</comment> |
98
|
|
|
project:parse |
99
|
|
|
project:run |
100
|
|
|
project:transform |
101
|
|
|
<comment>template</comment> |
102
|
|
|
template:generate |
103
|
|
|
template:list |
104
|
|
|
template:package</info> |
105
|
|
|
|
106
|
|
|
You can get a more detailed listing of the commands using the <info>list</info> |
107
|
|
|
command and get help by prepending the word <info>help</info> to the command |
108
|
|
|
name. |
109
|
|
|
HELP |
110
|
|
|
) |
111
|
|
|
->addOption( |
112
|
|
|
'target', |
113
|
|
|
't', |
114
|
|
|
InputOption::VALUE_OPTIONAL, |
115
|
|
|
'Path where to store the generated output' |
116
|
|
|
) |
117
|
|
|
->addOption( |
118
|
|
|
'cache-folder', |
119
|
|
|
null, |
120
|
|
|
InputOption::VALUE_OPTIONAL, |
121
|
|
|
'Path where to store the cache files' |
122
|
|
|
) |
123
|
|
|
->addOption( |
124
|
|
|
'filename', |
125
|
|
|
'f', |
126
|
|
|
InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, |
127
|
|
|
'Comma-separated list of files to parse. The wildcards ? and * are supported' |
128
|
|
|
) |
129
|
|
|
->addOption( |
130
|
|
|
'directory', |
131
|
|
|
'd', |
132
|
|
|
InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, |
133
|
|
|
'Comma-separated list of directories to (recursively) parse' |
134
|
|
|
) |
135
|
|
|
->addOption( |
136
|
|
|
'encoding', |
137
|
|
|
null, |
138
|
|
|
InputOption::VALUE_OPTIONAL, |
139
|
|
|
'encoding to be used to interpret source files with' |
140
|
|
|
) |
141
|
|
|
->addOption( |
142
|
|
|
'extensions', |
143
|
|
|
null, |
144
|
|
|
InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, |
145
|
|
|
'Comma-separated list of extensions to parse, defaults to php, php3 and phtml' |
146
|
|
|
) |
147
|
|
|
->addOption( |
148
|
|
|
'ignore', |
149
|
|
|
'i', |
150
|
|
|
InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, |
151
|
|
|
'Comma-separated list of file(s) and directories (relative to the source-code directory) that will be ' |
152
|
|
|
. 'ignored. Wildcards * and ? are supported' |
153
|
|
|
) |
154
|
|
|
->addOption( |
155
|
|
|
'ignore-tags', |
156
|
|
|
null, |
157
|
|
|
InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, |
158
|
|
|
'Comma-separated list of tags that will be ignored, defaults to none. package, subpackage and ignore ' |
159
|
|
|
. 'may not be ignored.' |
160
|
|
|
) |
161
|
|
|
->addOption( |
162
|
|
|
'hidden', |
163
|
|
|
null, |
164
|
|
|
InputOption::VALUE_NONE, |
165
|
|
|
'Use this option to tell phpDocumentor to parse files and directories that begin with a period (.), ' |
166
|
|
|
. 'by default these are ignored' |
167
|
|
|
) |
168
|
|
|
->addOption( |
169
|
|
|
'ignore-symlinks', |
170
|
|
|
null, |
171
|
|
|
InputOption::VALUE_NONE, |
172
|
|
|
'Ignore symlinks to other files or directories, default is on' |
173
|
|
|
) |
174
|
|
|
->addOption( |
175
|
|
|
'markers', |
176
|
|
|
'm', |
177
|
|
|
InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, |
178
|
|
|
'Comma-separated list of markers/tags to filter' |
179
|
|
|
) |
180
|
|
|
->addOption( |
181
|
|
|
'title', |
182
|
|
|
null, |
183
|
|
|
InputOption::VALUE_OPTIONAL, |
184
|
|
|
'Sets the title for this project; default is the phpDocumentor logo' |
185
|
|
|
) |
186
|
|
|
->addOption( |
187
|
|
|
'force', |
188
|
|
|
null, |
189
|
|
|
InputOption::VALUE_NONE, |
190
|
|
|
'Forces a full build of the documentation, does not increment existing documentation' |
191
|
|
|
) |
192
|
|
|
->addOption( |
193
|
|
|
'validate', |
194
|
|
|
null, |
195
|
|
|
InputOption::VALUE_NONE, |
196
|
|
|
'Validates every processed file using PHP Lint, costs a lot of performance' |
197
|
|
|
) |
198
|
|
|
->addOption( |
199
|
|
|
'visibility', |
200
|
|
|
null, |
201
|
|
|
InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, |
202
|
|
|
'Specifies the parse visibility that should be displayed in the documentation (comma separated e.g. ' |
203
|
|
|
. '"public,protected")' |
204
|
|
|
) |
205
|
|
|
->addOption( |
206
|
|
|
'defaultpackagename', |
207
|
|
|
null, |
208
|
|
|
InputOption::VALUE_OPTIONAL, |
209
|
|
|
'Name to use for the default package.', |
210
|
|
|
'Default' |
211
|
|
|
) |
212
|
|
|
->addOption( |
213
|
|
|
'sourcecode', |
214
|
|
|
null, |
215
|
|
|
InputOption::VALUE_NONE, |
216
|
|
|
'Whether to include syntax highlighted source code' |
217
|
|
|
) |
218
|
|
|
->addOption( |
219
|
|
|
'progressbar', |
220
|
|
|
'p', |
221
|
|
|
InputOption::VALUE_NONE, |
222
|
|
|
'Whether to show a progress bar; will automatically quiet logging to stdout' |
223
|
|
|
) |
224
|
|
|
->addOption( |
225
|
|
|
'template', |
226
|
|
|
null, |
227
|
|
|
InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, |
228
|
|
|
'Name of the template to use (optional)' |
229
|
|
|
) |
230
|
|
|
->addOption( |
231
|
|
|
'parseprivate', |
232
|
|
|
null, |
233
|
|
|
InputOption::VALUE_NONE, |
234
|
|
|
'Whether to parse DocBlocks marked with @internal tag' |
235
|
|
|
); |
236
|
|
|
|
237
|
|
|
parent::configure(); |
238
|
|
|
} |
239
|
|
|
|
240
|
|
|
/** |
241
|
|
|
* Executes the business logic involved with this command. |
242
|
|
|
* |
243
|
|
|
* @return int |
244
|
|
|
*/ |
245
|
|
|
protected function execute(InputInterface $input, OutputInterface $output) |
246
|
|
|
{ |
247
|
|
|
$pipeLine = $this->pipeline; |
248
|
|
|
$pipeLine($input->getOptions()); |
249
|
|
|
|
250
|
|
|
if ($output->getVerbosity() === OutputInterface::VERBOSITY_DEBUG) { |
251
|
|
|
file_put_contents('ast.dump', serialize($this->projectDescriptorBuilder->getProjectDescriptor())); |
252
|
|
|
} |
253
|
|
|
|
254
|
|
|
return 0; |
255
|
|
|
} |
256
|
|
|
} |
257
|
|
|
|