forked from Amadevus/pwsh-script
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-docs.ps1
38 lines (37 loc) · 1.21 KB
/
build-docs.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
#!/usr/bin/env pwsh
param([switch]$Clean)
$cmd = {
$core = Import-Module ./lib/GitHubActionsCore -PassThru -Scope Local -Force
$docsPath = 'docs/GitHubActionsCore'
if (-not (Test-Path $docsPath)) {
mkdir $docsPath | Out-Null
}
elseif ($Clean) {
Remove-Item $docsPath -Force -Recurse
}
Write-Output "| Cmdlet | Synopsis |" > $docsPath/README.md
Write-Output "|-|-|" >> $docsPath/README.md
$core.ExportedCommands.Values | ForEach-Object {
Get-Help $_.Name | Select-Object @{
Name = "Row"
Expression = {
$n = $_.Name.Trim()
$s = $_.Synopsis.Trim() -replace '\r?\n', ' '
"| [$($n)]($($n).md) | $($s) |"
}
}
} | Select-Object -Expand Row >> $docsPath/README.md
$core.ExportedCommands.Values | ForEach-Object {
Get-Help -Full $_.Name | Select-Object @{
Name = "Row"
Expression = {
$n = $_.Name.Trim()
"# $n"
"``````"
$_
"``````"
}
} | Select-Object -Expand Row > "$docsPath/$($_.Name).md"
}
}
pwsh -c $cmd -wd $PSScriptRoot