diff --git a/src/MarkdownReader/CommandHelpMarkdownReader.cs b/src/MarkdownReader/CommandHelpMarkdownReader.cs index b6433bdd..bc8a7daa 100644 --- a/src/MarkdownReader/CommandHelpMarkdownReader.cs +++ b/src/MarkdownReader/CommandHelpMarkdownReader.cs @@ -561,7 +561,7 @@ internal static string GetDescriptionFromMarkdown(ParsedMarkdownContent markdown diagnostics.Add(new DiagnosticMessage( DiagnosticMessageSource.Description, "DESCRIPTION header found", DiagnosticSeverity.Information, "DESCRIPTION", markdownContent.GetTextLine(start))); markdownContent.Seek(start); markdownContent.Take(); - var end = markdownContent.FindHeader(2, string.Empty); + var end = markdownContent.FindHeader(2, "EXAMPLES"); return markdownContent.GetStringFromAst(end).Trim(); } diff --git a/test/Pester/ImportMarkdownCommandHelp.Tests.ps1 b/test/Pester/ImportMarkdownCommandHelp.Tests.ps1 index b1c67028..c1028836 100644 --- a/test/Pester/ImportMarkdownCommandHelp.Tests.ps1 +++ b/test/Pester/ImportMarkdownCommandHelp.Tests.ps1 @@ -251,4 +251,14 @@ Describe 'Import-MarkdownCommandHelp Tests' { $ch.Syntax[$offset].ToString() | Should -Be $string } } + + Context 'Validate Description' { + BeforeAll { + $ch = Import-MarkdownCommandHelp "$PSScriptRoot/assets/Compare-CommandHelp2.md" + } + + It "Should handle empty description" { + $ch.Description | Should -BeNullOrEmpty + } + } } diff --git a/test/Pester/MeasurePlatyPSMarkdown.Tests.ps1 b/test/Pester/MeasurePlatyPSMarkdown.Tests.ps1 index 87f98e32..8f86e589 100644 --- a/test/Pester/MeasurePlatyPSMarkdown.Tests.ps1 +++ b/test/Pester/MeasurePlatyPSMarkdown.Tests.ps1 @@ -13,10 +13,10 @@ Describe "Export-MarkdownModuleFile" { It "Should identify all the '' assets" -TestCases @( @{ fileType = "unknown"; expectedCount = 2 } - @{ fileType = "CommandHelp"; expectedCount = 39 } + @{ fileType = "CommandHelp"; expectedCount = 40 } @{ fileType = "ModuleFile"; expectedCount = 14 } @{ fileType = "V1Schema"; expectedCount = 49 } - @{ fileType = "V2Schema"; expectedCount = 4 } + @{ fileType = "V2Schema"; expectedCount = 5 } ) { param ($fileType, $expectedCount) $idents.Where({($_.FileType -band $fileType) -eq $fileType}).Count | Should -Be $expectedCount diff --git a/test/Pester/assets/Compare-CommandHelp2.md b/test/Pester/assets/Compare-CommandHelp2.md new file mode 100644 index 00000000..c3927229 --- /dev/null +++ b/test/Pester/assets/Compare-CommandHelp2.md @@ -0,0 +1,114 @@ +--- +document type: cmdlet +external help file: Microsoft.PowerShell.PlatyPS.dll-Help.xml +HelpUri: '' +Locale: en-US +Module Name: Microsoft.PowerShell.PlatyPS +ms.date: 03/07/2025 +PlatyPS schema version: 2024-05-01 +title: Compare-CommandHelp +--- + +# Compare-CommandHelp + +## SYNOPSIS + +## SYNTAX + +### __AllParameterSets + +``` +Compare-CommandHelp [-ReferenceCommandHelp] [-DifferenceCommandHelp] + [-PropertyNamesToExclude ] [] +``` + +## ALIASES + +This cmdlet has the following aliases, + +## DESCRIPTION + +## EXAMPLES + +### Example 1 + +## PARAMETERS + +### -DifferenceCommandHelp + +```yaml +Type: Microsoft.PowerShell.PlatyPS.Model.CommandHelp +DefaultValue: '' +SupportsWildcards: false +ParameterValue: [] +Aliases: [] +ParameterSets: +- Name: (All) + Position: 1 + IsRequired: true + ValueFromPipeline: false + ValueFromPipelineByPropertyName: true + ValueFromRemainingArguments: false +DontShow: false +AcceptedValues: [] +HelpMessage: '' +``` + +### -PropertyNamesToExclude + +```yaml +Type: System.String[] +DefaultValue: '' +SupportsWildcards: false +ParameterValue: [] +Aliases: [] +ParameterSets: +- Name: (All) + Position: Named + IsRequired: false + ValueFromPipeline: false + ValueFromPipelineByPropertyName: false + ValueFromRemainingArguments: false +DontShow: false +AcceptedValues: [] +HelpMessage: '' +``` + +### -ReferenceCommandHelp + +```yaml +Type: Microsoft.PowerShell.PlatyPS.Model.CommandHelp +DefaultValue: '' +SupportsWildcards: false +ParameterValue: [] +Aliases: [] +ParameterSets: +- Name: (All) + Position: 0 + IsRequired: true + ValueFromPipeline: false + ValueFromPipelineByPropertyName: true + ValueFromRemainingArguments: false +DontShow: false +AcceptedValues: [] +HelpMessage: '' +``` + +### CommonParameters + +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, +-InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, +-ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see +[about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### Microsoft.PowerShell.PlatyPS.Model.CommandHelp + +## OUTPUTS + +### System.String + +## NOTES + +## RELATED LINKS