1 | <?php |
||||
2 | /** |
||||
3 | * @copyright Copyright (c) 2017 Julius Härtl <[email protected]> |
||||
4 | * @author Julius Härtl <[email protected]> |
||||
5 | * @license GNU AGPL version 3 or any later version |
||||
6 | * |
||||
7 | * This program is free software: you can redistribute it and/or modify |
||||
8 | * it under the terms of the GNU Affero General Public License as |
||||
9 | * published by the Free Software Foundation, either version 3 of the |
||||
10 | * License, or (at your option) any later version. |
||||
11 | * |
||||
12 | * This program is distributed in the hope that it will be useful, |
||||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
15 | * GNU Affero General Public License for more details. |
||||
16 | * |
||||
17 | * You should have received a copy of the GNU Affero General Public License |
||||
18 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
||||
19 | */ |
||||
20 | |||||
21 | namespace JuliusHaertl\PHPDocToRst; |
||||
22 | |||||
23 | use JuliusHaertl\PHPDocToRst\Extension\GithubLocationExtension; |
||||
24 | use JuliusHaertl\PHPDocToRst\Extension\NoPrivateExtension; |
||||
25 | use JuliusHaertl\PHPDocToRst\Extension\PublicOnlyExtension; |
||||
26 | use JuliusHaertl\PHPDocToRst\Extension\TocExtension; |
||||
27 | use Symfony\Component\Console\Command\Command; |
||||
28 | use Symfony\Component\Console\Input\InputArgument; |
||||
29 | use Symfony\Component\Console\Input\InputInterface; |
||||
30 | use Symfony\Component\Console\Input\InputOption; |
||||
31 | use Symfony\Component\Console\Output\OutputInterface; |
||||
32 | |||||
33 | /** |
||||
34 | * Class GenerateDocumentationCommand. |
||||
35 | * |
||||
36 | * @internal Only for use of the phpdoc-to-rst cli tool |
||||
37 | */ |
||||
38 | class GenerateDocumentationCommand extends Command |
||||
39 | { |
||||
40 | protected function configure() |
||||
41 | { |
||||
42 | $this->setName('generate')->setDescription('Generate documentation')->setHelp('This command allows you to generate sphinx/rst based documentation from PHPDoc annotations.')->addArgument( |
||||
43 | 'target', |
||||
44 | InputArgument::REQUIRED, |
||||
45 | 'Destination for the generated rst files' |
||||
46 | )->addArgument( |
||||
47 | 'src', |
||||
48 | InputArgument::IS_ARRAY, |
||||
49 | 'Source directories to parse' |
||||
50 | )->addOption( |
||||
51 | 'public-only', |
||||
52 | 'p', |
||||
53 | InputOption::VALUE_NONE |
||||
54 | )->addOption( |
||||
55 | 'show-private', |
||||
56 | null, |
||||
57 | InputOption::VALUE_NONE |
||||
58 | )->addOption( |
||||
59 | 'element-toc', |
||||
60 | 't', |
||||
61 | InputOption::VALUE_NONE |
||||
62 | )->addOption( |
||||
63 | 'repo-github', |
||||
64 | null, |
||||
65 | InputOption::VALUE_REQUIRED, |
||||
66 | 'Github URL of the projects git repository (requires --repo-base as well)', |
||||
67 | false |
||||
68 | )->addOption( |
||||
69 | 'repo-base', |
||||
70 | null, |
||||
71 | InputOption::VALUE_REQUIRED, |
||||
72 | 'Base path of the project git repository', |
||||
73 | false |
||||
74 | ); |
||||
75 | } |
||||
76 | |||||
77 | protected function execute(InputInterface $input, OutputInterface $output) |
||||
78 | { |
||||
79 | $src = $input->getArgument('src'); |
||||
80 | $dst = $input->getArgument('target'); |
||||
81 | |||||
82 | $apiDocBuilder = new ApiDocBuilder($src, $dst); |
||||
0 ignored issues
–
show
Bug
introduced
by
![]() It seems like
$src can also be of type string ; however, parameter $srcDir of JuliusHaertl\PHPDocToRst...cBuilder::__construct() does only seem to accept string[] , maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
83 | if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) { |
||||
84 | $apiDocBuilder->setVerboseOutput(true); |
||||
85 | } |
||||
86 | if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERY_VERBOSE) { |
||||
87 | $apiDocBuilder->setVerboseOutput(true); |
||||
88 | $apiDocBuilder->setDebugOutput(true); |
||||
89 | } |
||||
90 | if ($input->getOption('public-only')) { |
||||
91 | $apiDocBuilder->addExtension(PublicOnlyExtension::class); |
||||
92 | } |
||||
93 | if (!$input->getOption('show-private')) { |
||||
94 | $apiDocBuilder->addExtension(NoPrivateExtension::class); |
||||
95 | } |
||||
96 | if ($input->getOption('element-toc')) { |
||||
97 | $apiDocBuilder->addExtension(TocExtension::class); |
||||
98 | } |
||||
99 | |||||
100 | if ($input->getOption('repo-github') && $input->getOption('repo-base')) { |
||||
101 | $apiDocBuilder->addExtension(GithubLocationExtension::class, [ |
||||
102 | $input->getOption('repo-base'), |
||||
103 | $input->getOption('repo-github'), |
||||
104 | ]); |
||||
105 | } |
||||
106 | $apiDocBuilder->build(); |
||||
107 | } |
||||
108 | } |
||||
109 |