Skip to content

Commit 069f4d7

Browse files
Ensure the next header after description is examples while parsing MD (#755)
1 parent 35b887c commit 069f4d7

File tree

4 files changed

+127
-3
lines changed

4 files changed

+127
-3
lines changed

src/MarkdownReader/CommandHelpMarkdownReader.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,7 @@ internal static string GetDescriptionFromMarkdown(ParsedMarkdownContent markdown
561561
diagnostics.Add(new DiagnosticMessage( DiagnosticMessageSource.Description, "DESCRIPTION header found", DiagnosticSeverity.Information, "DESCRIPTION", markdownContent.GetTextLine(start)));
562562
markdownContent.Seek(start);
563563
markdownContent.Take();
564-
var end = markdownContent.FindHeader(2, string.Empty);
564+
var end = markdownContent.FindHeader(2, "EXAMPLES");
565565
return markdownContent.GetStringFromAst(end).Trim();
566566
}
567567

test/Pester/ImportMarkdownCommandHelp.Tests.ps1

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,4 +251,14 @@ Describe 'Import-MarkdownCommandHelp Tests' {
251251
$ch.Syntax[$offset].ToString() | Should -Be $string
252252
}
253253
}
254+
255+
Context 'Validate Description' {
256+
BeforeAll {
257+
$ch = Import-MarkdownCommandHelp "$PSScriptRoot/assets/Compare-CommandHelp2.md"
258+
}
259+
260+
It "Should handle empty description" {
261+
$ch.Description | Should -BeNullOrEmpty
262+
}
263+
}
254264
}

test/Pester/MeasurePlatyPSMarkdown.Tests.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ Describe "Export-MarkdownModuleFile" {
1313

1414
It "Should identify all the '<fileType>' assets" -TestCases @(
1515
@{ fileType = "unknown"; expectedCount = 2 }
16-
@{ fileType = "CommandHelp"; expectedCount = 39 }
16+
@{ fileType = "CommandHelp"; expectedCount = 40 }
1717
@{ fileType = "ModuleFile"; expectedCount = 14 }
1818
@{ fileType = "V1Schema"; expectedCount = 49 }
19-
@{ fileType = "V2Schema"; expectedCount = 4 }
19+
@{ fileType = "V2Schema"; expectedCount = 5 }
2020
) {
2121
param ($fileType, $expectedCount)
2222
$idents.Where({($_.FileType -band $fileType) -eq $fileType}).Count | Should -Be $expectedCount
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
---
2+
document type: cmdlet
3+
external help file: Microsoft.PowerShell.PlatyPS.dll-Help.xml
4+
HelpUri: ''
5+
Locale: en-US
6+
Module Name: Microsoft.PowerShell.PlatyPS
7+
ms.date: 03/07/2025
8+
PlatyPS schema version: 2024-05-01
9+
title: Compare-CommandHelp
10+
---
11+
12+
# Compare-CommandHelp
13+
14+
## SYNOPSIS
15+
16+
## SYNTAX
17+
18+
### __AllParameterSets
19+
20+
```
21+
Compare-CommandHelp [-ReferenceCommandHelp] <CommandHelp> [-DifferenceCommandHelp] <CommandHelp>
22+
[-PropertyNamesToExclude <string[]>] [<CommonParameters>]
23+
```
24+
25+
## ALIASES
26+
27+
This cmdlet has the following aliases,
28+
29+
## DESCRIPTION
30+
31+
## EXAMPLES
32+
33+
### Example 1
34+
35+
## PARAMETERS
36+
37+
### -DifferenceCommandHelp
38+
39+
```yaml
40+
Type: Microsoft.PowerShell.PlatyPS.Model.CommandHelp
41+
DefaultValue: ''
42+
SupportsWildcards: false
43+
ParameterValue: []
44+
Aliases: []
45+
ParameterSets:
46+
- Name: (All)
47+
Position: 1
48+
IsRequired: true
49+
ValueFromPipeline: false
50+
ValueFromPipelineByPropertyName: true
51+
ValueFromRemainingArguments: false
52+
DontShow: false
53+
AcceptedValues: []
54+
HelpMessage: ''
55+
```
56+
57+
### -PropertyNamesToExclude
58+
59+
```yaml
60+
Type: System.String[]
61+
DefaultValue: ''
62+
SupportsWildcards: false
63+
ParameterValue: []
64+
Aliases: []
65+
ParameterSets:
66+
- Name: (All)
67+
Position: Named
68+
IsRequired: false
69+
ValueFromPipeline: false
70+
ValueFromPipelineByPropertyName: false
71+
ValueFromRemainingArguments: false
72+
DontShow: false
73+
AcceptedValues: []
74+
HelpMessage: ''
75+
```
76+
77+
### -ReferenceCommandHelp
78+
79+
```yaml
80+
Type: Microsoft.PowerShell.PlatyPS.Model.CommandHelp
81+
DefaultValue: ''
82+
SupportsWildcards: false
83+
ParameterValue: []
84+
Aliases: []
85+
ParameterSets:
86+
- Name: (All)
87+
Position: 0
88+
IsRequired: true
89+
ValueFromPipeline: false
90+
ValueFromPipelineByPropertyName: true
91+
ValueFromRemainingArguments: false
92+
DontShow: false
93+
AcceptedValues: []
94+
HelpMessage: ''
95+
```
96+
97+
### CommonParameters
98+
99+
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable,
100+
-InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable,
101+
-ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see
102+
[about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216).
103+
104+
## INPUTS
105+
106+
### Microsoft.PowerShell.PlatyPS.Model.CommandHelp
107+
108+
## OUTPUTS
109+
110+
### System.String
111+
112+
## NOTES
113+
114+
## RELATED LINKS

0 commit comments

Comments
 (0)