-
Notifications
You must be signed in to change notification settings - Fork 2
/
build-docs.ps1
42 lines (32 loc) · 1 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
39
40
41
42
Set-Location $PSScriptRoot
if(-not (Test-Path .\Build)){
throw "Project must be built first"
}
$psd1 = Get-ChildItem .\Build -Filter 'PSDates.psd1' -Recurse | Select-Object -Last 1
Import-Module $psd1.FullName -Force
Get-ChildItem .\docs -Filter '*.md' | Remove-Item -Force
New-MarkdownHelp -Module PSDates -OutputFolder .\docs
$readme = Get-Content .\README.md
$docs = Get-ChildItem .\docs -Filter '*.md' | ForEach-Object{
$content = Get-Content -LiteralPath $_.FullName
"| [$($_.BaseName)](docs/$($_.Name)) | $($content[$content.IndexOf('## SYNOPSIS')+2]) |"
}
$commands = $false
$readmeupdate = foreach($line in $readme){
if($line -eq '# Commands'){
$commands = $true
$line
''
'| Cmdlet | Synopsis |'
'| ------ | -------- |'
$docs
''
}
elseif($commands -and $line -match '^#'){
$commands = $false
}
if(-not $commands){
$line
}
}
$readmeupdate | Out-File .\README.md