Skip to content

Commit 4d9fd9c

Browse files
authored
Merge pull request #3299 from microsoftgraph/fix-example-formatting
Updates example import script to fix formatting issues
2 parents 2bb827a + fbdb6a8 commit 4d9fd9c

File tree

4 files changed

+18
-10
lines changed

4 files changed

+18
-10
lines changed

src/DeviceManagement.Enrollment/beta/examples/New-MgBetaRoleManagementCloudPcRoleDefinition.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
### Example 1: Code snippet
1+
### Example 2: Code snippet
22

33
```powershell
44
55
Import-Module Microsoft.Graph.Beta.DeviceManagement.Enrollment
66
77
$params = @{
88
description = "An example custom role"
9-
### Example 2
9+
displayName = "ExampleCustomRole"
1010
rolePermissions = @(
1111
@{
1212
allowedResourceActions = @(

src/DeviceManagement.Enrollment/beta/examples/Update-MgBetaRoleManagementCloudPcRoleDefinition.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
### Example 1: Code snippet
1+
### Example 2: Code snippet
22

33
```powershell
44
55
Import-Module Microsoft.Graph.Beta.DeviceManagement.Enrollment
66
77
$params = @{
88
description = "Update basic properties and permission of application registrations"
9-
### Example 2
9+
displayName = "ExampleCustomRole"
1010
rolePermissions = @(
1111
@{
1212
allowedResourceActions = @(

src/readme.graph.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -957,11 +957,6 @@ directive:
957957
subject: ^User$
958958
set:
959959
alias: Set-Mg${subject-prefix}${subject}
960-
- where:
961-
verb: (Get|New|Update|Remove|Set|Invoke|Create)
962-
subject: ^(.*)(OnPremise)(.*)$
963-
set:
964-
alias: ^(.*)(OnPremises)(.*)$
965960

966961
# Setting the alias below as per the request on issue [#3241](https://github.com/microsoftgraph/msgraph-sdk-powershell/issues/3241)
967962

tools/ImportExamples.ps1

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,12 +268,14 @@ function Update-ExampleFile {
268268
$SearchTextForNewImports = "{{ Add description here }}"
269269
$ReplaceEverything = $False
270270
if ($HeaderList.Count -eq 0) {
271+
Write-Host "The header list is empty. Please check the external docs url."
271272
for ($d = 0; $d -lt $ExampleList.Count; $d++) {
272273
$sum = $d + 1
273274
$HL = $HeaderList.Add("### Example " + $sum + ": Code snippet".Trim())
274275
}
275276
}
276277
if ($HeaderList.Count -ne $ExampleList.Count) {
278+
Write-Host "The number of examples and the number of headers are not equal. Please check the external docs url."
277279
$HeaderList.Clear()
278280
for ($d = 0; $d -lt $ExampleList.Count; $d++) {
279281
$sum = $d + 1
@@ -286,6 +288,14 @@ function Update-ExampleFile {
286288
}
287289
$HeadCount = $HeaderList.Count
288290
$ExampleCount = $ExampleList.Count
291+
#On the example list check the one that contains the command pattern and if doesn't match remove it from the list. Also remove the header from the header list
292+
for ($x = 0; $x -lt $HeaderList.Count; $x++) {
293+
if ($ExampleList[$x] -notmatch "\b$CommandPattern\b") {
294+
$ExampleList.RemoveAt($x)
295+
$HeaderList.RemoveAt($x)
296+
}
297+
}
298+
289299
$WrongExamplesCount = 0;
290300
$SkippedExample = -1
291301
$TotalText = ""
@@ -298,9 +308,12 @@ function Update-ExampleFile {
298308
Clear-Content $ExampleFile -Force
299309
for ($d = 0; $d -lt $HeaderList.Count; $d++) {
300310
$CodeValue = $ExampleList[$d].Trim()
311+
301312
if ($CodeValue -match "\b$CommandPattern\b") {
313+
Write-Host $CodeValue
302314
$TitleValue = $HeaderList[$d].Trim()
303315
$TitleDesc = $TitleValue
316+
304317
if (-not($TitleValue.Contains("Code snippet"))) {
305318
if ($TitleDesc -match $DescriptionRegex) {
306319
$TitleDesc = $TitleDesc -replace $DescriptionRegex, ''
@@ -593,4 +606,4 @@ Start-Generator -ModulesToGenerate $ModulesToGenerate -GenerationMode "auto"
593606

594607
#4. Test for beta updates from api reference
595608
#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"
596-
#Start-Generator -GenerationMode "manual" -ManualExternalDocsUrl "https://learn.microsoft.com/en-us/graph/api/synchronization-synchronization-list-templates?view=graph-rest-beta&tabs=powershell" -GraphCommand "Get-MgBetaServicePrincipalSynchronizationTemplate" -GraphModule "Applications" -Profile "beta"
609+
#Start-Generator -GenerationMode "manual" -ManualExternalDocsUrl "https://learn.microsoft.com/graph/api/rbacapplication-post-roledefinitions?view=graph-rest-beta" -GraphCommand "New-MgBetaRoleManagementCloudPcRoleDefinition" -GraphModule "DeviceManagement.Enrollment" -Profile "beta"

0 commit comments

Comments
 (0)