Skip to content

Commit 5c57c3e

Browse files
authored
Fix NOTES section formatting in comment-based help (PowerShell#26512)
1 parent 11f91df commit 5c57c3e

2 files changed

Lines changed: 28 additions & 4 deletions

File tree

src/System.Management.Automation/FormatAndOutput/DefaultFormatters/Help_format_ps1xml.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -680,10 +680,7 @@ private static IEnumerable<FormatViewDefinition> ViewsOf_MamlCommandHelpInfo_Ful
680680
.StartFrame(leftIndent: 4)
681681
.AddPropertyExpressionBinding(@"title")
682682
.AddNewline()
683-
.AddNewline()
684-
.StartFrame(leftIndent: 4)
685-
.AddPropertyExpressionBinding(@"alert", enumerateCollection: true, customControl: sharedControls[11])
686-
.EndFrame()
683+
.AddPropertyExpressionBinding(@"alert", enumerateCollection: true, customControl: sharedControls[11])
687684
.AddNewline()
688685
.EndFrame()
689686
.EndEntry()
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Copyright (c) Microsoft Corporation.
2+
# Licensed under the MIT License.
3+
4+
Describe 'Comment-based help NOTES section formatting' -Tags "CI", "Feature" {
5+
It 'NOTES section should have single blank line after header and 4-space indentation' {
6+
$helpText = Get-Help Remove-PSSession -Full | Out-String
7+
$lines = $helpText -split "`r?`n"
8+
9+
# Find NOTES section
10+
$notesIndex = -1
11+
for ($i = 0; $i -lt $lines.Count; $i++) {
12+
if ($lines[$i] -match '^NOTES\s*$') {
13+
$notesIndex = $i
14+
break
15+
}
16+
}
17+
18+
$notesIndex | Should -BeGreaterThan -1 -Because "NOTES section should exist"
19+
20+
# The line after NOTES header should be blank
21+
$lines[$notesIndex + 1] | Should -Match '^\s*$' -Because "There should be a blank line after NOTES header"
22+
23+
# The second line after NOTES header should have content with 4-space indentation
24+
$contentLine = $lines[$notesIndex + 2]
25+
$contentLine | Should -Match '^[ ]{4}\S' -Because "Content should have exactly 4-space indentation"
26+
}
27+
}

0 commit comments

Comments
 (0)