Skip to content

Commit fcf7aa0

Browse files
author
Maddie Clayton
authored
Merge pull request #6537 from maddieclayton/docsscript
Add script to generate output types for docs
2 parents f97a904 + 972bfda commit fcf7aa0

File tree

3 files changed

+56
-1
lines changed

3 files changed

+56
-1
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,8 @@ pingme.txt
218218
groupMapping*.json
219219
/tools/index.json
220220
/Package/index.json
221+
/tools/outputtypes.json
222+
/Package/outputtypes.json
221223

222224
*.msi
223225
*.wixpdb

build.proj

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@
280280

281281
<Exec ContinueOnError="false"
282282
Command="&quot;$(PowerShellCommand)&quot; -NonInteractive -NoLogo -NoProfile -Command &quot; . $(LibraryToolsFolder)\NewHelpIndex.ps1 -OutputFile $(PackageDirectory)\index.json -BuildConfig $(Configuration) &quot;"
283-
Condition=" '$(Scope)' == 'All' or '$(Scope)' == 'Latest' and $(CodeSign) == 'true'"/>
283+
Condition=" ('$(Scope)' == 'All' or '$(Scope)' == 'Latest') and $(CodeSign) == 'true'"/>
284284

285285
<!-- Copying modules to be signed -->
286286

@@ -314,6 +314,11 @@
314314
Condition= " '$(Scope)' == 'All' or '$(Scope)' == 'Stack' "/>
315315

316316
<CallTarget Targets="CodeSignBinaries" Condition=" '$(CodeSign)' == 'true' " />
317+
318+
<Exec ContinueOnError="false"
319+
Command="&quot;$(PowerShellCommand)&quot; -NonInteractive -NoLogo -NoProfile -Command &quot; . $(LibraryToolsFolder)\NewOutputTypeIndex.ps1 -OutputFile $(PackageDirectory)\outputtypes.json -BuildConfig $(Configuration) &quot;"
320+
Condition=" ('$(Scope)' == 'All' or '$(Scope)' == 'Latest') and $(CodeSign) == 'true'"/>
321+
317322
<!-- AzureRM -->
318323
<Copy SourceFiles="$(PackageDirectory)\$(Configuration)\AzureRM.psd1"
319324
DestinationFolder="$(LibraryToolsFolder)\AzureRM" Condition= " '$(Scope)' == 'All' or '$(Scope)' == 'Latest' "/>

tools/NewOutputTypeIndex.ps1

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
param(
2+
[Parameter(Mandatory = $false)]
3+
[string] $BuildConfig = "Debug",
4+
[Parameter(Mandatory = $false)]
5+
[string] $OutputFile = "$PSScriptRoot/outputtypes.json"
6+
)
7+
8+
# Get all psd1 files
9+
$psd1Files = Get-Childitem $PSScriptRoot\..\src\Package\$BuildConfig\ResourceManager -Recurse | where {$_.Name -like "*.psd1" }
10+
$psd1Files += Get-Childitem $PSScriptRoot\..\src\Package\$BuildConfig\Storage -Recurse | where {$_.Name -like "*.psd1" }
11+
12+
$profilePsd1 = $psd1Files | Where-Object {$_.Name -like "*AzureRM.Profile.psd1"}
13+
Import-LocalizedData -BindingVariable "psd1File" -BaseDirectory $profilePsd1.DirectoryName -FileName $profilePsd1.Name
14+
foreach ($nestedModule in $psd1File.RequiredAssemblies)
15+
{
16+
$dllPath = Join-Path -Path $profilePsd1.DirectoryName -ChildPath $nestedModule
17+
$Assembly = [Reflection.Assembly]::LoadFrom($dllPath)
18+
}
19+
20+
21+
$outputTypes = New-Object System.Collections.Generic.HashSet[string]
22+
23+
$psd1Files | ForEach {
24+
Import-LocalizedData -BindingVariable "psd1File" -BaseDirectory $_.DirectoryName -FileName $_.Name
25+
foreach ($nestedModule in $psd1File.NestedModules)
26+
{
27+
$dllPath = Join-Path -Path $_.DirectoryName -ChildPath $nestedModule
28+
$Assembly = [Reflection.Assembly]::LoadFrom($dllPath)
29+
$exportedTypes = $Assembly.GetTypes()
30+
foreach ($exportedType in $exportedTypes)
31+
{
32+
foreach ($attribute in $exportedType.CustomAttributes)
33+
{
34+
if ($attribute.AttributeType.Name -eq "OutputTypeAttribute")
35+
{
36+
$cmdletOutputTypes = $attribute.ConstructorArguments.Value.Value
37+
foreach ($cmdletOutputType in $cmdletOutputTypes)
38+
{
39+
$outputTypes.Add($cmdletOutputType.FullName) | Out-Null
40+
}
41+
}
42+
}
43+
}
44+
}
45+
}
46+
47+
$json = ConvertTo-Json $outputTypes
48+
$json | Out-File "$OutputFile"

0 commit comments

Comments
 (0)