-
Notifications
You must be signed in to change notification settings - Fork 0
/
Invoke-GenerateDocs.ps1
53 lines (38 loc) · 1.56 KB
/
Invoke-GenerateDocs.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
[CmdletBinding()]
param(
[Parameter(Mandatory = $true)]
[string] $ModuleName,
[Parameter(Mandatory = $true)]
[string] $ModuleVersion,
[Parameter(Mandatory = $false)]
[string] $OutputFolder
)
begin {
if ([string]::IsNullOrWhiteSpace($OutputFolder)) {
$OutputFolder = Join-Path -Path $PSScriptRoot -ChildPath 'docs'
}
if (-not (Test-Path -Path $OutputFolder)) {
New-Item -Path $OutputFolder -ItemType 'Directory' | Out-Null
}
[string] $OutputDirectory = Join-Path -Path $OutputFolder -ChildPath $ModuleName
if (-not (Test-Path -Path $OutputDirectory)) {
New-Item -Path $OutputDirectory -ItemType 'Directory' | Out-Null
}
[string] $VersionedOutputDirectory = Join-Path -Path $OutputDirectory -ChildPath $ModuleVersion
if (-not (Test-Path -Path $VersionedOutputDirectory)) {
New-Item -Path $VersionedOutputDirectory -ItemType 'Directory' | Out-Null
}
$Module = Get-Module -Name $ModuleName -ListAvailable | Where-Object -Property 'Version' -EQ $ModuleVersion
if ($null -eq $Module) {
Install-Module -Name $ModuleName -RequiredVersion $ModuleVersion -Scope 'CurrentUser'
$Module = Get-Module -Name $ModuleName -ListAvailable | Where-Object -Property 'Version' -EQ $ModuleVersion
}
if ($null -eq (Get-Module -Name $ModuleName)) {
Import-Module -Name $ModuleName -RequiredVersion $ModuleVersion
}
}
process {
New-MarkdownHelp -Module $ModuleName -Encoding ([System.Text.Encoding]::UTF8) -OutputFolder $VersionedOutputDirectory -Force
}
end {
}