forked from Azure/azure-powershell
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate-help.ps1
74 lines (64 loc) · 3.36 KB
/
generate-help.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# ----------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Code generated by Microsoft (R) AutoRest Code Generator.Changes may cause incorrect behavior and will be lost if the code
# is regenerated.
# ----------------------------------------------------------------------------------
param([switch]$Isolated)
$ErrorActionPreference = 'Stop'
$pwsh = [System.Diagnostics.Process]::GetCurrentProcess().Path
if(-not $Isolated) {
Write-Host -ForegroundColor Green 'Creating isolated process...'
& "$pwsh" -NonInteractive -NoLogo -NoProfile -File $MyInvocation.MyCommand.Path @PSBoundParameters -Isolated
return
}
$exportsFolder = Join-Path $PSScriptRoot 'exports'
if(-not (Test-Path $exportsFolder)) {
Write-Error "Exports folder '$exportsFolder' was not found."
}
$directories = Get-ChildItem -Directory -Path $exportsFolder
$hasProfiles = ($directories | Measure-Object).Count -gt 0
if(-not $hasProfiles) {
$directories = Get-Item -Path $exportsFolder
}
$docsFolder = Join-Path $PSScriptRoot 'docs'
if(Test-Path $docsFolder) {
$null = Get-ChildItem -Path $docsFolder -Recurse -Exclude 'README.md' | Remove-Item -Recurse -ErrorAction SilentlyContinue
}
$null = New-Item -ItemType Directory -Force -Path $docsFolder -ErrorAction SilentlyContinue
$examplesFolder = Join-Path $PSScriptRoot 'examples'
$modulePsd1 = Get-Item -Path (Join-Path $PSScriptRoot './Az.DataMigration.psd1')
$modulePath = $modulePsd1.FullName
$moduleName = $modulePsd1.BaseName
# Load DLL to use build-time cmdlets
Import-Module -Name $modulePath
Import-Module -Name (Join-Path $PSScriptRoot './bin/Az.DataMigration.private.dll')
$instance = [Microsoft.Azure.PowerShell.Cmdlets.DataMigration.Module]::Instance
# Module info is shared per profile
$moduleInfo = Get-Module -Name $moduleName
foreach($directory in $directories)
{
if($hasProfiles) {
Select-AzProfile -Name $directory.Name
}
# Reload module per profile
Import-Module -Name $modulePath -Force
$cmdletNames = Get-ScriptCmdlet -ScriptFolder $directory.FullName
$cmdletHelpInfo = $cmdletNames | ForEach-Object { Get-Help -Name $_ -Full }
$cmdletFunctionInfo = Get-ScriptCmdlet -ScriptFolder $directory.FullName -AsFunctionInfo
$docsPath = Join-Path $docsFolder $directory.Name
$null = New-Item -ItemType Directory -Force -Path $docsPath -ErrorAction SilentlyContinue
$examplesPath = Join-Path $examplesFolder $directory.Name
$addComplexInterfaceInfo = ![System.Convert]::ToBoolean('true')
Export-HelpMarkdown -ModuleInfo $moduleInfo -FunctionInfo $cmdletFunctionInfo -HelpInfo $cmdletHelpInfo -DocsFolder $docsPath -ExamplesFolder $examplesPath -AddComplexInterfaceInfo:$addComplexInterfaceInfo
Write-Host -ForegroundColor Green "Created documentation in '$docsPath'"
}
Write-Host -ForegroundColor Green '-------------Done-------------'