4
4
Param (
5
5
$ModulesToGenerate = @ (),
6
6
[string ] $ModuleMappingConfigPath = (Join-Path $PSScriptRoot " ../microsoftgraph/config\ModulesMapping.jsonc" ),
7
- [string ] $WorkLoadDocsPath = (Join-Path $PSScriptRoot " ../microsoftgraph" ),
8
- [string ] $CmdletMetadataPath = (Join-Path $PSScriptRoot " ../msgraph-sdk-powershell/src/Authentication/Authentication/custom/common/MgCommandMetadata.json" )
7
+ [string ] $WorkLoadDocsPath = (Join-Path $PSScriptRoot " ../microsoftgraph" )
9
8
)
10
9
function Get-GraphMapping {
11
10
$graphMapping = @ {}
12
11
$graphMapping.Add (" v1.0" , " graph-powershell-1.0" )
13
12
$graphMapping.Add (" beta" , " graph-powershell-beta" )
14
13
return $graphMapping
15
14
}
16
- function Set -Help {
15
+ function Generate -Help {
17
16
param (
18
17
[ValidateNotNullOrEmpty ()]
19
18
[string ] $ModuleDocsPath ,
20
19
[ValidateNotNullOrEmpty ()]
21
- [string ] $Command ,
22
- [ValidateNotNullOrEmpty ()]
23
- [string ]$Module
20
+ [string ] $Module
24
21
)
25
-
26
22
$generationParams = @ {
27
- Command = $Command
23
+ Module = $Module
28
24
OutputFolder = $ModuleDocsPath
29
25
AlphabeticParamsOrder = $true
26
+ WithModulePage = $true
30
27
ExcludeDontShow = $true
31
- Force = $true
32
28
Encoding = [System.Text.Encoding ]::UTF8
33
29
}
34
-
35
- if ($Module -eq " Microsoft.Graph.Authentication" ) {
36
- $generationParams = @ {
37
- Module = $Module
38
- OutputFolder = $ModuleDocsPath
39
- AlphabeticParamsOrder = $true
40
- ExcludeDontShow = $true
41
- WithModulePage = $true
42
- Encoding = [System.Text.Encoding ]::UTF8
43
- }
44
- Import-Module $Module - Force - Global
45
- }
46
30
New-MarkdownHelp @generationParams
47
31
}
48
32
49
- function Start -GraphHelp {
33
+ function Generate -GraphHelp {
50
34
Param (
51
35
$ModulesToGenerate = @ ()
52
36
)
@@ -56,6 +40,7 @@ function Start-GraphHelp {
56
40
$AuthPath = " $ModulePrefix .Authentication"
57
41
$AuthDestination = Join-Path $WorkLoadDocsPath " graph-powershell-1.0" $AuthPath
58
42
Get-ChildItem - Path $AuthDestination * - File - Recurse | foreach { $_.Delete () }
43
+ Generate- GraphModuleHelp - GraphProfile " v1.0" - GraphProfilePath " graph-powershell-1.0" - ModuleName " Authentication" - ModulePrefix $ModulePrefix
59
44
60
45
Import-Module Microsoft.Graph.Authentication - Global
61
46
$GraphMapping = Get-GraphMapping
@@ -65,10 +50,8 @@ function Start-GraphHelp {
65
50
if ($graphProfile -eq " beta" ) {
66
51
$profilePath = " graph-powershell-beta"
67
52
}
68
-
69
- $AuthenticationDocsPath = Join-Path $PSScriptRoot " ..\microsoftgraph\graph-powershell-1.0\Microsoft.Graph.Authentication"
70
- Set-Help - ModuleDocsPath $AuthenticationDocsPath - Command " AuthCommands" - Module " Microsoft.Graph.Authentication"
71
- Get-FolderByProfile - GraphProfile $graphProfile - GraphProfilePath $profilePath - ModulePrefix $ModulePrefix - ModulesToGenerate $ModulesToGenerate
53
+ Get-FolderByProfile - GraphProfile $graphProfile - GraphProfilePath $profilePath - ModulePrefix $ModulePrefix - ModulesToGenerate $ModulesToGenerate
54
+ Generate- GraphHelpByProfile - GraphProfile $graphProfile - GraphProfilePath $GraphMapping [$graphProfile ] - ModulePrefix $ModulePrefix - ModulesToGenerate $ModulesToGenerate
72
55
}
73
56
git config
-- global user.email
" [email protected] "
74
57
git config -- global user.name " Microsoft Graph DevX Tooling"
@@ -87,61 +70,70 @@ function Get-FolderByProfile {
87
70
[ValidateNotNullOrEmpty ()]
88
71
$ModulesToGenerate = @ ()
89
72
)
90
- $CommandMetadataContent = Get-Content $CmdletMetadataPath | ConvertFrom-Json
91
73
92
74
$ModulesToGenerate | ForEach-Object {
93
75
$ModuleName = $_
94
- $ModName = $ModuleName
95
76
$Path = " $ModulePrefix .$ModuleName "
96
77
if ($GraphProfile -eq ' beta' ) {
97
78
$Path = " $ModulePrefix .Beta.$ModuleName "
98
- $ModName = " Beta.$ModuleName "
99
79
}
100
80
$Destination = Join-Path $WorkLoadDocsPath $GraphProfilePath $Path
101
81
if (-not (Test-Path $Destination )) {
102
82
New-Item - Path $Destination - ItemType Directory
103
83
}
104
84
105
85
Get-ChildItem - Path $Destination * - File - Recurse | foreach { $_.Delete () }
106
- $CmdletCount = 0
107
- # Generate table of contents for each module
108
- $TocFileName = " $Path .md"
109
- $ModuleGuid = [guid ]::NewGuid().ToString()
110
- $LinkProfile = $GraphProfile.Replace (" v" , " " )
111
- $LinkModuleName = $Path.ToLower ()
112
- $HelpVersion = " 1.0.0.0"
113
- $HelpLocale = " en-US"
114
- $DownloadLink = " https://learn.microsoft.com/en-us/powershell/module/$LinkModuleName /?view=graph-powershell-$LinkProfile "
115
- New-Item - Path $Destination - Name $TocFileName - ItemType File - Force
116
- Add-Content - Path $Destination \$TocFileName - Value " ---"
117
- Add-Content - Path $Destination \$TocFileName - Value " Module Name: $Path "
118
- Add-Content - Path $Destination \$TocFileName - Value " Module Guid: $ModuleGuid "
119
- Add-Content - Path $Destination \$TocFileName - Value " Download Help Link: $DownloadLink "
120
- Add-Content - Path $Destination \$TocFileName - Value " Help Version: $HelpVersion "
121
- Add-Content - Path $Destination \$TocFileName - Value " Locale: $HelpLocale "
122
- Add-Content - Path $Destination \$TocFileName - Value " ---"
123
- Add-Content - Path $Destination \$TocFileName - Value " "
124
- Add-Content - Path $Destination \$TocFileName - Value " # $Path Module"
125
- Add-Content - Path $Destination \$TocFileName - Value " ## Description"
126
- Add-Content - Path $Destination \$TocFileName - Value " Microsoft Graph PowerShell Cmdlets"
127
- Add-Content - Path $Destination \$TocFileName - Value " "
128
- Add-Content - Path $Destination \$TocFileName - Value " ## $Path Cmdlets"
129
- $CommandMetadataContent | Where-Object { $_.Module -eq $ModName -and $_.ApiVersion -eq $GraphProfile } | ForEach-Object {
130
- $Command = $_.Command
131
- $CmdletDocsPath = Join-Path $WorkLoadDocsPath $GraphProfilePath $Path " $Command .md"
132
- if (-not (Test-Path $CmdletDocsPath )) {
133
- Set-Help - ModuleDocsPath $Destination - Command $Command - Module $Path
86
+ }
87
+
88
+ }
89
+ function Generate-GraphHelpByProfile {
90
+ Param (
91
+ [ValidateSet (" beta" , " v1.0" )]
92
+ [string ] $GraphProfile = " v1.0" ,
93
+ [ValidateNotNullOrEmpty ()]
94
+ [string ] $GraphProfilePath = " graph-powershell-1.0" ,
95
+ [ValidateNotNullOrEmpty ()]
96
+ [string ] $ModulePrefix = " Microsoft.Graph" ,
97
+ [ValidateNotNullOrEmpty ()]
98
+ $ModulesToGenerate = @ ()
99
+ )
100
+ $ModulesToGenerate | ForEach-Object {
101
+ $ModuleName = $_
102
+ Generate- GraphModuleHelp - GraphProfile $GraphProfile - GraphProfilePath $GraphProfilePath - ModuleName $ModuleName - ModulePrefix $ModulePrefix
103
+ }
104
+ }
105
+
106
+ function Generate-GraphModuleHelp {
107
+ param (
108
+ [ValidateSet (" beta" , " v1.0" )]
109
+ [string ] $GraphProfile = " v1.0" ,
110
+ [ValidateNotNullOrEmpty ()]
111
+ [string ] $GraphProfilePath = " graph-powershell-1.0" ,
112
+ [ValidateNotNullOrEmpty ()]
113
+ [string ] $ModuleName = " Users" ,
114
+ [ValidateNotNullOrEmpty ()]
115
+ [string ] $ModulePrefix = " Microsoft.Graph"
116
+ )
117
+ try {
118
+ $Module = " $ModulePrefix .$ModuleName "
119
+ if ($Module -ne " Microsoft.Graph.WindowsUpdates" ) {
120
+ $Path = " $ModulePrefix .$ModuleName "
121
+ if ($GraphProfile -eq ' beta' ) {
122
+ $Module = " $ModulePrefix .Beta.$ModuleName "
123
+ $Path = " $ModulePrefix .Beta.$ModuleName "
134
124
}
135
- Add-Content - Path $Destination \$TocFileName - Value " ### [$Command ]($Command .md)"
136
- Add-Content - Path $Destination \$TocFileName - Value " "
137
- $CmdletCount ++
138
- }
139
- if ($CmdletCount -eq 0 ){
140
- Remove-Item - LiteralPath $Destination - Force - Recurse
141
- }
125
+ $ModuleDocsPath = Join-Path $PSScriptRoot " ..\microsoftgraph\$GraphProfilePath \$Path "
142
126
127
+ Import-Module $Module - Force - Global
128
+ Generate- Help - ModuleDocsPath $ModuleDocsPath - Module $Module
129
+ }
130
+ }
131
+ catch {
132
+ Write-Host " `n Error Message: " $_.Exception.Message
133
+ Write-Host " `n Error in Line: " $_.InvocationInfo.Line
134
+ Write-Host " `n Error in Line Number: " $_.InvocationInfo.ScriptLineNumber
135
+ Write-Host " `n Error Item Name: " $_.Exception.ItemName
143
136
}
144
-
145
137
}
146
138
# Install PlatyPS
147
139
if (! (Get-Module - Name PlatyPS - ListAvailable)) {
@@ -162,5 +154,5 @@ if ($ModulesToGenerate.Count -eq 0) {
162
154
$ModulesToGenerate = $ModuleMapping.Keys
163
155
}
164
156
Write-Host - ForegroundColor Green " -------------finished checking out to today's branch-------------"
165
- Start -GraphHelp - ModulesToGenerate $ModulesToGenerate
157
+ Generate - GraphHelp - ModulesToGenerate $ModulesToGenerate
166
158
Write-Host - ForegroundColor Green " -------------Done-------------"
0 commit comments