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 Exception; |
19
|
|
|
use League\Pipeline\PipelineInterface; |
20
|
|
|
use Symfony\Component\Console\Command\Command; |
21
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
22
|
|
|
use Symfony\Component\Console\Input\InputOption; |
23
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Transforms the structure file into the specified output format |
27
|
|
|
* |
28
|
|
|
* This task will execute the transformation rules described in the given |
29
|
|
|
* template (defaults to 'responsive') with the given source (defaults to |
30
|
|
|
* output/structure.xml) and writes these to the target location (defaults to |
31
|
|
|
* 'output'). |
32
|
|
|
* |
33
|
|
|
* It is possible for the user to receive additional information using the |
34
|
|
|
* verbose option or stop additional information using the quiet option. Please |
35
|
|
|
* take note that the quiet option also disables logging to file. |
36
|
|
|
*/ |
37
|
|
|
final class TransformCommand extends Command |
38
|
|
|
{ |
39
|
|
|
/** |
40
|
|
|
* @var PipelineInterface |
41
|
|
|
*/ |
42
|
|
|
private $pipeline; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Initializes the command with all necessary dependencies to construct human-suitable output from the AST. |
46
|
|
|
*/ |
47
|
|
|
public function __construct(PipelineInterface $pipeline) |
48
|
|
|
{ |
49
|
|
|
parent::__construct('project:transform'); |
50
|
|
|
$this->pipeline = $pipeline; |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* Initializes this command and sets the name, description, options and |
55
|
|
|
* arguments. |
56
|
|
|
*/ |
57
|
|
|
protected function configure(): void |
58
|
|
|
{ |
59
|
|
|
$this->setAliases(['transform']) |
60
|
|
|
->setDescription( |
61
|
|
|
'Converts the PHPDocumentor structure file to documentation' |
62
|
|
|
) |
63
|
|
|
->setHelp( |
64
|
|
|
<<<TEXT |
65
|
|
|
This task will execute the transformation rules described in the given |
66
|
|
|
template (defaults to 'responsive') with the given source (defaults to |
67
|
|
|
output/structure.xml) and writes these to the target location (defaults to |
68
|
|
|
'output'). |
69
|
|
|
|
70
|
|
|
It is possible for the user to receive additional information using the |
71
|
|
|
verbose option or stop additional information using the quiet option. Please |
72
|
|
|
take note that the quiet option also disables logging to file. |
73
|
|
|
TEXT |
74
|
|
|
); |
75
|
|
|
|
76
|
|
|
$this->addOption( |
77
|
|
|
'source', |
78
|
|
|
's', |
79
|
|
|
InputOption::VALUE_OPTIONAL, |
80
|
|
|
'Path where the XML source file is located (optional)' |
81
|
|
|
); |
82
|
|
|
$this->addOption( |
83
|
|
|
'target', |
84
|
|
|
't', |
85
|
|
|
InputOption::VALUE_OPTIONAL, |
86
|
|
|
'Path where to store the generated output (optional)' |
87
|
|
|
); |
88
|
|
|
$this->addOption( |
89
|
|
|
'template', |
90
|
|
|
null, |
91
|
|
|
InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, |
92
|
|
|
'Name of the template to use (optional)' |
93
|
|
|
); |
94
|
|
|
|
95
|
|
|
parent::configure(); |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
/** |
99
|
|
|
* Executes the business logic involved with this command. |
100
|
|
|
* |
101
|
|
|
* @throws Exception if the provided source is not an existing file or a folder. |
102
|
|
|
*/ |
103
|
|
|
protected function execute(InputInterface $input, OutputInterface $output): int |
104
|
|
|
{ |
105
|
|
|
$pipeLine = $this->pipeline; |
106
|
|
|
$pipeLine($input->getOptions()); |
107
|
|
|
|
108
|
|
|
return 0; |
109
|
|
|
} |
110
|
|
|
} |
111
|
|
|
|