Skip to content

Commit d26a202

Browse files
committed
Removed part that adds boiler plate code
1 parent 412eba8 commit d26a202

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

tools/ImportExamples.ps1

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -300,16 +300,15 @@ function Update-ExampleFile {
300300
$H = $HeaderList.Add("Example " + $sum + ": Code snippet".Trim())
301301
}
302302
}
303-
if (($Content | Select-String -pattern $SearchTextForNewImports)) {
303+
$EmptyFile = Test-FileEmpty $ExampleFile
304+
if ($EmptyFile -or ($Content | Select-String -pattern $SearchTextForNewImports)) {
304305
$ReplaceEverything = $True
305306
}
306-
307307
$HeadCount = $HeaderList.Count
308308
$ExampleCount = $ExampleList.Count
309309
$WrongExamplesCount = 0;
310310
$SkippedExample = -1
311311
$ContainsRightExamples = $False
312-
313312
#===========================Importing new examples into files ============================================#
314313
if ($ReplaceEverything -and $ExampleCount -gt 0 -and $HeadCount -eq $ExampleCount) {
315314
Clear-Content $ExampleFile -Force
@@ -367,11 +366,6 @@ function Update-ExampleFile {
367366
if ($Content | Select-String -pattern $CommandPattern) {
368367
Retain-ExistingCorrectExamples -Content $Content -File $ExampleFile -CommandPattern $CommandPattern
369368
}
370-
else {
371-
#Replace everything with boiler plate code
372-
$DefaultBoilerPlate = "### Example 1: {{ Add title here }}`r`n``````powershell`r`n PS C:\> {{ Add code here }}`r`n`n{{ Add output here }}`r`n```````n`n{{ Add description here }}`r`n`n### Example 2: {{ Add title here }}`r`n``````powershell`r`n PS C:\> {{ Add code here }}`r`n`n{{ Add output here }}`r`n```````n`n{{ Add description here }}`r`n`n"
373-
Add-Content -Path $ExampleFile -Value $DefaultBoilerPlate.Trim()
374-
}
375369
}
376370

377371
}
@@ -413,8 +407,6 @@ function Update-ExampleFile {
413407
#-----------------------------------------------------------------------------------------------------------------------------------------------------------------#
414408
if (($WrongExamplesCount -gt 0) -and -not($ContainsRightExamples)) {
415409
Clear-Content $ExampleFile -Force
416-
$DefaultBoilerPlate = "### Example 1: {{ Add title here }}`r`n``````powershell`r`n PS C:\> {{ Add code here }}`r`n`n{{ Add output here }}`r`n```````n`n{{ Add description here }}`r`n`n### Example 2: {{ Add title here }}`r`n``````powershell`r`n PS C:\> {{ Add code here }}`r`n`n{{ Add output here }}`r`n```````n`n{{ Add description here }}`r`n`n"
417-
Add-Content -Path $ExampleFile -Value $DefaultBoilerPlate.Trim()
418410
#Log api path api version and equivalent external doc url giving wron examples
419411
#Create folder and file if it doesn't exist
420412
#The artifact below will be ignored on git.
@@ -439,7 +431,7 @@ function Test-FileEmpty {
439431

440432
Param ([Parameter(Mandatory = $true)][string]$File)
441433

442-
if ((Test-Path -LiteralPath $file) -and !((Get-Content -LiteralPath $file -Raw) -match '\S')) { return $true } else { return $false }
434+
if ((Test-Path -LiteralPath $File) -and !((Get-Content -LiteralPath $File -Raw) -match '\S')) { return $true } else { return $false }
443435

444436
}
445437

@@ -597,4 +589,4 @@ Start-Generator -ModulesToGenerate $ModulesToGenerate -GenerationMode "auto"
597589

598590
#4. Test for beta updates from api reference
599591
#Start-Generator -GenerationMode "manual" -ManualExternalDocsUrl "https://docs.microsoft.com/graph/api/serviceprincipal-post-approleassignedto?view=graph-rest-beta" -GraphCommand "New-MgBetaServicePrincipalAppRoleAssignedTo" -GraphModule "Applications" -Profile "beta"
600-
#Start-Generator -GenerationMode "manual" -ManualExternalDocsUrl "https://learn.microsoft.com/en-us/graph/api/identitygovernance-run-get?view=graph-rest-beta&tabs=http" -GraphCommand "Get-MgBetaIdentityGovernanceLifecycleWorkflowDeletedItemWorkflowRun" -GraphModule "Identity.Governance" -Profile "beta"
592+
#Start-Generator -GenerationMode "manual" -ManualExternalDocsUrl "https://learn.microsoft.com/en-us/graph/api/identitygovernance-run-get?view=graph-rest-beta&tabs=http" -GraphCommand "Get-MgBetaGroupCalendarPermission" -GraphModule "Calendar" -Profile "beta"

0 commit comments

Comments
 (0)