Skip to content

Commit 4a4ef90

Browse files
committed
Fix bug in HelpGeneration script that is failing the on-demand build, add checks that will prevent infinite looping within a file
1 parent 421e69e commit 4a4ef90

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

tools/HelpGeneration/HelpGeneration.psm1

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,11 @@ function Validate-MarkdownHelp
118118
if ($content[$idx+1] -notcontains "## SYNTAX")
119119
{
120120
$idx++
121+
if ($idx -ge $content.Length)
122+
{
123+
Write-Error "Could not find SYNTAX header in file $($file.Name)"
124+
return
125+
}
121126
}
122127
elseif ($content[$idx] -contains "{{Fill in the Synopsis}}")
123128
{
@@ -147,6 +152,11 @@ function Validate-MarkdownHelp
147152
if ($content[$idx+1] -notcontains "## EXAMPLES")
148153
{
149154
$idx++
155+
if ($idx -ge $content.Length)
156+
{
157+
Write-Error "Could not find EXAMPLES header in file $($file.Name)"
158+
return
159+
}
150160
}
151161
elseif ($content[$idx] -contains "{{Fill in the Description}}")
152162
{
@@ -167,9 +177,14 @@ function Validate-MarkdownHelp
167177
"## EXAMPLES"
168178
{
169179
# Move the index to the start of the PowerShell code
170-
while ($content[$idx] -notcontains "``````")
180+
while ($content[$idx] -notcontains "``````" -and $content[$idx] -notcontains "``````powershell")
171181
{
172182
$idx++
183+
if ($idx -ge $content.Length)
184+
{
185+
Write-Error "Could not find start of PowerShell example in file $($file.Name)"
186+
return
187+
}
173188
}
174189

175190
# Check for the platyPS example template

0 commit comments

Comments
 (0)