-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdoc.ps1
53 lines (36 loc) · 1.42 KB
/
doc.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
Import-Module powershell-yaml
# yaml specs folders
$yml = 'yml'
$ymlResources = "$yml\resources"
$ymlBindings = "$yml\bindings"
# eps telpates forlders
$eps = 'eps'
# generated md folder
$md = 'doc'
$mdResources = "$md\resources"
$mdBindings = "$md\bindings"
# delete all previous doc folders
if (Test-Path -Path $md) {
Remove-Item -Recurse -Force $md
}
# create doc folders
New-Item -ItemType directory -Path $md | Out-Null
New-Item -ItemType directory -Path $mdResources | Out-Null
New-Item -ItemType directory -Path $mdBindings | Out-Null
$resources = @{}
$bindings = @{}
foreach($resource in Get-ChildItem $ymlResources -File) {
$name = $resource.Name -Replace '\.yml'
Write-Host $name
$yaml = Get-Content -Raw $resource.FullName | ConvertFrom-Yaml -Ordered
$resources[$name] = $yaml
Invoke-EpsTemplate -Path "$eps\resource.eps" -Binding @{ name = $name; resource = $yaml } | Set-Content "$mdResources\$name.md"
}
foreach($binding in Get-ChildItem $ymlBindings -File) {
$name = $binding.Name -Replace '\.yml'
Write-Host $name
$yaml = Get-Content -Raw $binding.FullName | ConvertFrom-Yaml -Ordered
$bindings[$name] = $yaml
Invoke-EpsTemplate -Path "$eps\binding.eps" -Binding @{ name = $name; binding = $yaml } | Set-Content "$mdBindings\$name.md"
}
Invoke-EpsTemplate -Path "$eps\README.eps" -Binding @{ resources = $resources; bindings = $bindings } | Set-Content "README.md"