Skip to content

Commit c964a11

Browse files
authored
Merge pull request #650 from MicrosoftDocs/main
Changes from main to live
2 parents 670314d + a084791 commit c964a11

File tree

3 files changed

+104
-2
lines changed

3 files changed

+104
-2
lines changed

.openpublishing.redirection.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
},
88
{
99
"source_path": "microsoftgraph/docs-conceptual/tutorial-grant-delegated-api-permissions.md",
10-
"redirect_url": "https://learn.microsoft.com/powershell/microsoftgraph/how-to-grant-revoke-api-permissions&pivots=grant-delegated-permissions",
10+
"redirect_url": "https://learn.microsoft.com/powershell/microsoftgraph/how-to-grant-revoke-api-permissions?pivots=grant-delegated-permissions",
1111
"redirect_document_id": false
1212
},
1313
{
1414
"source_path": "microsoftgraph/docs-conceptual/tutorial-grant-app-only-api-permissions.md",
15-
"redirect_url": "https://learn.microsoft.com/powershell/microsoftgraph/how-to-grant-revoke-api-permissions&pivots=grant-application-permissions",
15+
"redirect_url": "https://learn.microsoft.com/powershell/microsoftgraph/how-to-grant-revoke-api-permissions?pivots=grant-application-permissions",
1616
"redirect_document_id": false
1717
},
1818
{

azure-pipelines/powershell-docs.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,13 @@ extends:
137137
targetType: 'filePath'
138138
pwsh: true
139139
filePath: scripts/RemoveBoilerPlateCode.ps1
140+
- task: PowerShell@2
141+
displayName: 'Remove invalid fullstops'
142+
continueOnError: false
143+
inputs:
144+
targetType: 'filePath'
145+
pwsh: true
146+
filePath: scripts/RemoveInvalidFullStops.ps1
140147
- task: PowerShell@2
141148
displayName: 'Generate missing docs for aliased cmdlets'
142149
continueOnError: false

scripts/RemoveInvalidFullStops.ps1

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
# Copyright (c) Microsoft Corporation. All rights reserved.
2+
# Licensed under the MIT License.
3+
Param(
4+
$ModulesToGenerate = @(),
5+
[string] $ModuleMappingConfigPath = (Join-Path $PSScriptRoot "../microsoftgraph/config/ModulesMapping.jsonc")
6+
)
7+
function Get-GraphMapping {
8+
$graphMapping = @{}
9+
$graphMapping.Add("v1.0", "graph-powershell-1.0")
10+
$graphMapping.Add("beta", "graph-powershell-beta")
11+
return $graphMapping
12+
}
13+
14+
function Remove-InvalidFullStops {
15+
Param(
16+
$ModulesToGenerate = @()
17+
)
18+
19+
$ModulePrefix = "Microsoft.Graph"
20+
$GraphMapping = Get-GraphMapping
21+
$GraphMapping.Keys | ForEach-Object {
22+
$graphProfile = $_
23+
Get-FilesByProfile -GraphProfile $graphProfile -GraphProfilePath $GraphMapping[$graphProfile] -ModulePrefix $ModulePrefix -ModulesToGenerate $ModulesToGenerate
24+
}
25+
26+
git config --global user.email "[email protected]"
27+
git config --global user.name "Timothy Wamalwa"
28+
git add .
29+
git commit -m "Removed invalid full stops from the beginning of lines"
30+
}
31+
function Get-FilesByProfile {
32+
Param(
33+
[ValidateSet("beta", "v1.0")]
34+
[string] $GraphProfile = "v1.0",
35+
[ValidateNotNullOrEmpty()]
36+
[string] $GraphProfilePath = "graph-powershell-1.0",
37+
[ValidateNotNullOrEmpty()]
38+
[string] $ModulePrefix = "Microsoft.Graph",
39+
[ValidateNotNullOrEmpty()]
40+
$ModulesToGenerate = @()
41+
)
42+
43+
$ModulesToGenerate | ForEach-Object {
44+
$ModuleName = $_
45+
Get-Files -GraphProfile $GraphProfile -GraphProfilePath $GraphProfilePath -Module $ModuleName -ModulePrefix $ModulePrefix
46+
}
47+
48+
}
49+
function Get-Files {
50+
param(
51+
[ValidateSet("beta", "v1.0")]
52+
[string] $GraphProfile = "v1.0",
53+
[ValidateNotNullOrEmpty()]
54+
[string] $GraphProfilePath = "graph-powershell-1.0",
55+
[ValidateNotNullOrEmpty()]
56+
[string] $Module = "Users",
57+
[ValidateNotNullOrEmpty()]
58+
[string] $ModulePrefix = "Microsoft.Graph"
59+
)
60+
if ($GraphProfile -eq "beta") {
61+
$ModulePrefix = "Microsoft.Graph.Beta"
62+
}
63+
$moduleImportName = "$ModulePrefix.$ModuleName"
64+
$moduleDocsPath = Join-Path $PSScriptRoot "..\microsoftgraph\$GraphProfilePath\$moduleImportName"
65+
Update-Files -ModuleDocsPath $moduleDocsPath
66+
67+
}
68+
69+
70+
71+
function Update-Files {
72+
Param(
73+
[ValidateNotNullOrEmpty()]
74+
[string] $ModuleDocsPath
75+
)
76+
$files = Get-ChildItem -Path $ModuleDocsPath -Filter *.md -Recurse
77+
$files | ForEach-Object {
78+
$FilePath = $_.FullName
79+
# Read the file and remove any full stops at the beginning of a line
80+
(Get-Content $FilePath) -replace '^\.', '' | Set-Content $FilePath
81+
}
82+
}
83+
84+
if (-not (Test-Path $ModuleMappingConfigPath)) {
85+
Write-Error "Module mapping file not be found: $ModuleMappingConfigPath."
86+
}
87+
if ($ModulesToGenerate.Count -eq 0) {
88+
[HashTable] $ModuleMapping = Get-Content $ModuleMappingConfigPath | ConvertFrom-Json -AsHashTable
89+
$ModulesToGenerate = $ModuleMapping.Keys
90+
}
91+
Remove-InvalidFullStops -ModulesToGenerate $ModulesToGenerate
92+
93+
94+
95+

0 commit comments

Comments
 (0)