Skip to content

Commit d6cda49

Browse files
Refactor Update-MDSection to simplify warning handling and remove SkipIfMissing parameter; update markdown lint rules for clarity; delete unused abbreviation-preview.js script
1 parent 80b2ab2 commit d6cda49

3 files changed

Lines changed: 30 additions & 139 deletions

File tree

.github/actions/update-index/src/Helper.psm1

Lines changed: 20 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -92,52 +92,41 @@ function Update-MDSection {
9292

9393
# The new content to insert between the section markers.
9494
[Parameter()]
95-
[string] $Content,
96-
97-
# Skip update when the target file or section markers are missing.
98-
[Parameter()]
99-
[switch] $SkipIfMissing
95+
[string] $Content
10096
)
10197

10298
$startSegment = "<!-- $Name`_START -->"
10399
$endSegment = "<!-- $Name`_END -->"
104100

105-
if (-not (Test-Path -Path $Path)) {
106-
if ($SkipIfMissing) {
107-
Write-Warning "[$Name] Skipping update because target file was not found: $Path"
108-
return
101+
function Write-UpdateWarning {
102+
param([string] $Message)
103+
104+
Write-Warning $Message
105+
if ($env:GITHUB_ACTIONS -eq 'true') {
106+
Write-Output "::warning::$Message"
109107
}
108+
}
110109

111-
throw "[$Name] Target file was not found: $Path"
110+
if (-not (Test-Path -Path $Path)) {
111+
Write-UpdateWarning "[$Name] Skipping update because target file was not found: $Path"
112+
return
112113
}
113114

114115
$currentContent = Get-Content -Path $Path
115116
$startIndex = $currentContent.IndexOf($startSegment)
116117
$endIndex = $currentContent.IndexOf($endSegment)
117118

118119
if ($startIndex -lt 0) {
119-
if ($SkipIfMissing) {
120-
Write-Warning "[$Name] Skipping update because the start marker was not found in: $Path"
121-
return
122-
}
123-
124-
throw "[$Name] The start comment segment was not found in the file."
120+
Write-UpdateWarning "[$Name] Skipping update because the start marker was not found in: $Path"
121+
return
125122
}
126123
if ($endIndex -lt 0) {
127-
if ($SkipIfMissing) {
128-
Write-Warning "[$Name] Skipping update because the end marker was not found in: $Path"
129-
return
130-
}
131-
132-
throw "[$Name] The end comment segment was not found in the file."
124+
Write-UpdateWarning "[$Name] Skipping update because the end marker was not found in: $Path"
125+
return
133126
}
134127
if ($endIndex -lt $startIndex) {
135-
if ($SkipIfMissing) {
136-
Write-Warning "[$Name] Skipping update because marker order is invalid in: $Path"
137-
return
138-
}
139-
140-
throw "[$Name] The end comment segment was found before the start comment segment."
128+
Write-UpdateWarning "[$Name] Skipping update because marker order is invalid in: $Path"
129+
return
141130
}
142131

143132
$updatedContent = $currentContent[0..$startIndex] + $Content + $currentContent[($endIndex)..($currentContent.Length - 1)]
@@ -202,7 +191,7 @@ function Update-ActionList {
202191
$actionTableRows</table>
203192
204193
"@
205-
Update-MDSection -Path '.\src\docs\GitHub-Actions\index.md' -Name 'ACTION_LIST' -Content $actionTable -SkipIfMissing
194+
Update-MDSection -Path '.\src\docs\GitHub-Actions\index.md' -Name 'ACTION_LIST' -Content $actionTable
206195
}
207196

208197
function Update-ModuleList {
@@ -258,7 +247,7 @@ $moduleTableRows</table>
258247
259248
"@
260249

261-
Update-MDSection -Path '.\src\docs\PowerShell\Modules\index.md' -Name 'MODULE_LIST' -Content $moduleTable -SkipIfMissing
250+
Update-MDSection -Path '.\src\docs\PowerShell\Modules\index.md' -Name 'MODULE_LIST' -Content $moduleTable
262251
}
263252

264253
function Update-FunctionAppList {
@@ -318,5 +307,5 @@ $functionAppTableRows</table>
318307
319308
"@
320309

321-
Update-MDSection -Path '.\src\docs\PowerShell\FunctionApps\index.md' -Name 'FUNCTIONAPP_LIST' -Content $functionAppTable -SkipIfMissing
310+
Update-MDSection -Path '.\src\docs\PowerShell\FunctionApps\index.md' -Name 'FUNCTIONAPP_LIST' -Content $functionAppTable
322311
}

.github/linters/.markdown-lint.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,20 @@
88
###############
99
# Rules by id #
1010
###############
11-
MD004: false # Unordered list style
11+
MD004: false # Unordered list style
1212
MD007:
13-
indent: 2 # Unordered list indentation
13+
indent: 2 # Unordered list indentation
1414
MD013:
15-
line_length: 3000 # Line length
16-
MD025: false # Allow front-matter title + visible H1 on docs pages
15+
line_length: 3000 # Line length
16+
MD025: false # Allow front-matter title + visible H1 on docs pages
1717
MD026:
18-
punctuation: ".,;:!。,;:" # List of not allowed
19-
MD029: false # Ordered list item prefix
20-
MD033: false # Allow inline HTML
21-
MD036: false # Emphasis used instead of a heading
22-
MD041: false # First line in file should be a top level heading, PULL_REQUEST_TEMPLATE.md is an exception
18+
punctuation: '.,;:!。,;:' # List of not allowed
19+
MD029: false # Ordered list item prefix
20+
MD033: false # Allow inline HTML
21+
MD036: false # Emphasis used instead of a heading
22+
MD041: false # First line in file should be a top level heading, PULL_REQUEST_TEMPLATE.md is an exception
2323

2424
#################
2525
# Rules by tags #
2626
#################
27-
blank_lines: false # Error on blank lines
27+
blank_lines: false # Error on blank lines

src/overrides/assets/javascripts/abbreviation-preview.js

Lines changed: 0 additions & 98 deletions
This file was deleted.

0 commit comments

Comments
 (0)