forked from AutomatedLab/AutomatedLab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
NewOrUpdateHelp.ps1
56 lines (48 loc) · 1.68 KB
/
NewOrUpdateHelp.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
54
55
56
param
(
[switch]
$Create,
[string[]]
$Module = @('AutomatedLabUnattended' # Careful... This is also the import order!
'AutomatedLabTest',
'PSLog',
'PSFileTransfer',
'AutomatedLabDefinition',
'AutomatedLabWorker',
'HostsFile',
'AutomatedLabNotifications',
'AutomatedLab',
'AutomatedLab.Recipe')
)
$location = $PSScriptRoot
$outPath = foreach ($moduleName in $Module)
{
$outputFolder = Join-Path $location -ChildPath "Help/$moduleName/en-us"
$outputFolder
Import-Module ./$moduleName -Force
if ($Create.IsPresent)
{
$null = New-MarkdownHelp -Module $moduleName -WithModulePage -OutputFolder $outputFolder -Force
}
}
if (-not $Create.IsPresent)
{
Update-MarkdownHelpModule -Path $outPath -RefreshModulePage
}
# Update mkdocs.yml as part of a new help commit
$mkdocs = Join-Path -Path $location -ChildPath mkdocs.yml -Resolve -ErrorAction Stop
$mkdocsContent = Get-Content -Raw -Path $mkdocs | ConvertFrom-Yaml
$null = ($mkdocsContent.nav | Where-Object {$_.Keys -contains 'Module help'})['Module help'] = New-Object System.Collections.ArrayList
foreach ($moduleName in ($Module | Sort-Object))
{
$moduleObject = @{$moduleName = New-Object System.Collections.ArrayList}
foreach ($command in (Get-Command -Module $moduleName))
{
$commandObject = @{
$command.Name = "$moduleName/en-us/$($command.Name).md"
}
$null = $moduleObject.$moduleName.Add($commandObject)
}
$null = ($mkdocsContent.nav | Where-Object {$_.Keys -contains 'Module help'})['Module help'].Add($moduleObject)
}
$mkdocsContent | ConvertTo-Yaml -OutFile $mkdocs -Force