1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* This file is part of phpDocumentor. |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
* |
11
|
|
|
* @link https://phpdoc.org |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
namespace phpDocumentor\Pipeline\Stage; |
15
|
|
|
|
16
|
|
|
use phpDocumentor\Configuration\VersionSpecification; |
17
|
|
|
use phpDocumentor\Descriptor\ApiSetDescriptor; |
18
|
|
|
use phpDocumentor\Descriptor\Collection; |
19
|
|
|
use phpDocumentor\Descriptor\Collection as PartialsCollection; |
20
|
|
|
use phpDocumentor\Descriptor\DocumentationSetDescriptor; |
21
|
|
|
use phpDocumentor\Descriptor\GuideSetDescriptor; |
22
|
|
|
use phpDocumentor\Descriptor\VersionDescriptor; |
23
|
|
|
use function md5; |
24
|
|
|
|
25
|
|
|
final class InitializeBuilderFromConfig |
26
|
|
|
{ |
27
|
|
|
/** @var PartialsCollection<string> */ |
28
|
|
|
private $partials; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @param PartialsCollection<string> $partials |
|
|
|
|
32
|
|
|
*/ |
33
|
1 |
|
public function __construct(PartialsCollection $partials) |
34
|
|
|
{ |
35
|
1 |
|
$this->partials = $partials; |
36
|
1 |
|
} |
37
|
|
|
|
38
|
1 |
|
public function __invoke(Payload $payload) : Payload |
39
|
|
|
{ |
40
|
1 |
|
$configuration = $payload->getConfig(); |
41
|
|
|
|
42
|
1 |
|
$builder = $payload->getBuilder(); |
43
|
1 |
|
$builder->createProjectDescriptor(); |
44
|
1 |
|
$builder->setName($configuration['phpdocumentor']['title'] ?? ''); |
45
|
1 |
|
$builder->setPartials($this->partials); |
46
|
1 |
|
$builder->setCustomSettings($configuration['phpdocumentor']['settings'] ?? []); |
47
|
|
|
|
48
|
1 |
|
foreach ($configuration['phpdocumentor']['versions'] as $version) { |
49
|
|
|
$builder->addVersion( |
50
|
|
|
$this->buildVersion( |
51
|
|
|
$version |
52
|
|
|
) |
53
|
|
|
); |
54
|
|
|
} |
55
|
|
|
|
56
|
1 |
|
return $payload; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
private function buildVersion(VersionSpecification $version) : VersionDescriptor |
60
|
|
|
{ |
61
|
|
|
$collection = Collection::fromClassString(DocumentationSetDescriptor::class); |
62
|
|
|
foreach ($version->getGuides() as $guide) { |
|
|
|
|
63
|
|
|
$collection->add( |
64
|
|
|
new GuideSetDescriptor(md5($guide['output']), $guide['source'], $guide['output'], $guide['format']) |
|
|
|
|
65
|
|
|
); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
foreach ($version->getApi() as $apiSpecification) { |
69
|
|
|
$collection->add( |
70
|
|
|
new ApiSetDescriptor( |
|
|
|
|
71
|
|
|
md5($apiSpecification['output']), |
72
|
|
|
$apiSpecification['source'], |
73
|
|
|
$apiSpecification['output'], |
74
|
|
|
$apiSpecification |
75
|
|
|
) |
76
|
|
|
); |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
return new VersionDescriptor( |
80
|
|
|
$version->getNumber(), |
81
|
|
|
$collection |
82
|
|
|
); |
83
|
|
|
} |
84
|
|
|
} |
85
|
|
|
|
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.