|
1
|
|
|
<?php declare(strict_types=1); |
|
2
|
|
|
|
|
3
|
|
|
require('vendor/autoload.php'); |
|
4
|
|
|
|
|
5
|
|
|
use Formularium\Element; |
|
6
|
|
|
use Formularium\Formularium; |
|
7
|
|
|
use HaydenPierce\ClassFinder\ClassFinder; |
|
8
|
|
|
|
|
9
|
|
|
use function Safe\file_put_contents; |
|
10
|
|
|
|
|
11
|
|
|
function validators() |
|
12
|
|
|
{ |
|
13
|
|
|
$validators = Formularium::getValidatorNames(); |
|
14
|
|
|
|
|
15
|
|
|
$markdown = []; |
|
16
|
|
|
|
|
17
|
|
|
foreach ($validators as $className => $name) { |
|
18
|
|
|
$markdown[$name] = $className::getMetadata()->toMarkdown(); |
|
19
|
|
|
} |
|
20
|
|
|
|
|
21
|
|
|
ksort($markdown); |
|
22
|
|
|
|
|
23
|
|
|
$validatorAPI = ' |
|
24
|
|
|
# Validators |
|
25
|
|
|
|
|
26
|
|
|
List of validators and its parameters generated automatically. |
|
27
|
|
|
|
|
28
|
|
|
' . join("\n", $markdown); |
|
29
|
|
|
|
|
30
|
|
|
file_put_contents(__DIR__ . '/../docs/api-validators.md', $validatorAPI); |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
function datatypes() |
|
34
|
|
|
{ |
|
35
|
|
|
$datatypes = Formularium::getDatatypeNames(); |
|
|
|
|
|
|
36
|
|
|
|
|
37
|
|
|
$markdown = []; |
|
|
|
|
|
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
function elements() |
|
41
|
|
|
{ |
|
42
|
|
|
$frameworks = [ |
|
43
|
|
|
'Bootstrap', |
|
44
|
|
|
'Buefy', |
|
45
|
|
|
'Bulma', |
|
46
|
|
|
'HTML', |
|
47
|
|
|
'Materialize' |
|
48
|
|
|
]; |
|
49
|
|
|
|
|
50
|
|
|
foreach ($frameworks as $framework) { |
|
51
|
|
|
$markdown = []; |
|
52
|
|
|
$ns = "Formularium\\Frontend\\$framework\\Element"; |
|
53
|
|
|
|
|
54
|
|
|
/** @var array<class-string> $classesInNamespace */ |
|
55
|
|
|
$classesInNamespace = ClassFinder::getClassesInNamespace($ns); |
|
56
|
|
|
|
|
57
|
|
|
foreach ($classesInNamespace as $className) { |
|
58
|
|
|
$reflection = new \ReflectionClass($className); |
|
59
|
|
|
if (!$reflection->isInstantiable()) { |
|
60
|
|
|
continue; |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
if (!is_a($className, Element::class, true)) { |
|
64
|
|
|
continue; |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
$metadata = $className::getMetadata(); |
|
68
|
|
|
|
|
69
|
|
|
$markdown[$metadata->name] = $metadata->toMarkdown(); |
|
70
|
|
|
} |
|
71
|
|
|
ksort($markdown); |
|
72
|
|
|
|
|
73
|
|
|
$elementAPI = " |
|
74
|
|
|
# Elements for $framework |
|
75
|
|
|
|
|
76
|
|
|
List of elements for $framework and its parameters. |
|
77
|
|
|
|
|
78
|
|
|
" . join("\n", $markdown); |
|
79
|
|
|
|
|
80
|
|
|
file_put_contents(__DIR__ . "'/../docs/api-$framework-elements.md", $elementAPI); |
|
81
|
|
|
} |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
validators(); |
|
85
|
|
|
elements(); |
|
86
|
|
|
|