@@ -82,19 +82,20 @@ function Get-Files {
82
82
83
83
# Extract command over here
84
84
$Command = [System.IO.Path ]::GetFileNameWithoutExtension($File )
85
- # Extract URI path
86
- $CommandDetails = Find-MgGraphCommand - Command $Command
87
- if ($CommandDetails ) {
88
- foreach ($CommandDetail in $CommandDetails ) {
89
- $ApiPath = $CommandDetail.URI
90
- $Method = $CommandDetails.Method
91
- Get-ExternalDocsUrl - GraphProfile $GraphProfile - UriPath $ApiPath - Command $Command - OpenApiContent $OpenApiContent - GraphProfilePath $GraphProfilePath - Method $Method.Trim () - Module $Module
85
+ if ($Command -ine " README" ) {
86
+ # Extract URI path
87
+ $CommandDetails = Find-MgGraphCommand - Command $Command
88
+ if ($CommandDetails ) {
89
+ foreach ($CommandDetail in $CommandDetails ) {
90
+ $ApiPath = $CommandDetail.URI
91
+ $Method = $CommandDetails.Method
92
+ Get-ExternalDocsUrl - GraphProfile $GraphProfile - UriPath $ApiPath - Command $Command - OpenApiContent $OpenApiContent - GraphProfilePath $GraphProfilePath - Method $Method.Trim () - Module $Module
93
+ }
92
94
}
93
- }
94
- else {
95
- # Clear any content in that file as long as its not a readme file
96
- if ($Command -ine " README" ) {
95
+ else {
96
+ # Clear any content in that file as long as its not a readme file
97
97
Clear-Content $File - Force
98
+
98
99
}
99
100
}
100
101
}
@@ -182,10 +183,12 @@ function Get-ExternalDocsUrl {
182
183
}
183
184
if (-not ([string ]::IsNullOrEmpty($ExternalDocUrl ))) {
184
185
Start-WebScrapping - GraphProfile $GraphProfile - ExternalDocUrl $ExternalDocUrl - Command $Command - GraphProfilePath $GraphProfilePath - UriPath $UriPath - Module $Module
185
- }else {
186
+ }
187
+ else {
186
188
# This step will still correct the examples if the external docs url is not found
187
189
$ExampleFile = " $GraphProfilePath /$Command .md"
188
190
Retain- ExistingCorrectExamples - Content (Get-Content $ExampleFile ) - File $ExampleFile - CommandPattern $Command
191
+
189
192
}
190
193
}
191
194
@@ -216,17 +219,17 @@ function Start-WebScrapping {
216
219
[string ] $Module = " Users" ,
217
220
[string ] $GraphProfilePath = (Join-Path $PSScriptRoot " ..\src\Users\Users\examples\v1.0" )
218
221
)
219
- $ExternalDocUrlPaths = $ExternalDocUrl.Split (" ://" )[1 ].Split(" /" )
220
- $LastExternalDocUrlPathSegmentWithQueryParam = $ExternalDocUrlPaths [$ExternalDocUrlPaths.Length - 1 ]
221
- $LastExternalDocUrlPathSegmentWithoutQueryParam = $LastExternalDocUrlPathSegmentWithQueryParam.Split (" ?" )[0 ]
222
-
223
- $GraphDocsUrl = " https://raw.githubusercontent.com/microsoftgraph/microsoft-graph-docs-contrib/main/api-reference/$GraphProfile /api/$LastExternalDocUrlPathSegmentWithoutQueryParam .md"
224
- $UrlPaths = $GraphDocsUrl.Split (" ://" )[1 ].Split(" /" )
225
- $LastPathSegment = $UrlPaths [$UrlPaths.Length - 1 ]
226
- $HeaderList = New-Object - TypeName ' System.Collections.ArrayList' ;
227
- $ExampleLinks = New-Object - TypeName ' System.Collections.ArrayList' ;
228
- $Snippets = New-Object - TypeName ' System.Collections.ArrayList' ;
229
- try {
222
+ $ExternalDocUrlPaths = $ExternalDocUrl.Split (" ://" )[1 ].Split(" /" )
223
+ $LastExternalDocUrlPathSegmentWithQueryParam = $ExternalDocUrlPaths [$ExternalDocUrlPaths.Length - 1 ]
224
+ $LastExternalDocUrlPathSegmentWithoutQueryParam = $LastExternalDocUrlPathSegmentWithQueryParam.Split (" ?" )[0 ]
225
+
226
+ $GraphDocsUrl = " https://raw.githubusercontent.com/microsoftgraph/microsoft-graph-docs-contrib/main/api-reference/$GraphProfile /api/$LastExternalDocUrlPathSegmentWithoutQueryParam .md"
227
+ $UrlPaths = $GraphDocsUrl.Split (" ://" )[1 ].Split(" /" )
228
+ $LastPathSegment = $UrlPaths [$UrlPaths.Length - 1 ]
229
+ $HeaderList = New-Object - TypeName ' System.Collections.ArrayList' ;
230
+ $ExampleLinks = New-Object - TypeName ' System.Collections.ArrayList' ;
231
+ $Snippets = New-Object - TypeName ' System.Collections.ArrayList' ;
232
+ try {
230
233
($readStream , $HttpWebResponse ) = FetchStream - GraphDocsUrl $GraphDocsUrl
231
234
232
235
while (-not $readStream.EndOfStream ) {
@@ -275,7 +278,8 @@ function Start-WebScrapping {
275
278
$Description = " This example shows how to use the $DescriptionCommand Cmdlet."
276
279
277
280
Update-ExampleFile - GraphProfile $GraphProfile - HeaderList $HeaderList - ExampleList $Snippets - ExampleFile $ExampleFile - Description $Description - Command $Command - ExternalDocUrl $url - UriPath $UriPath - Module $Module
278
- }catch {
281
+ }
282
+ catch {
279
283
Write-Host " `n Error Message: " $_.Exception.Message
280
284
Write-Host " `n Error in Line: " $_.InvocationInfo.Line
281
285
Write-Host " `n Error in Line Number: " $_.InvocationInfo.ScriptLineNumber
0 commit comments