From 4475a5d7ae84148ab43d1f848b7b6ab44ff2f1f1 Mon Sep 17 00:00:00 2001 From: Aditya Patwardhan Date: Mon, 12 May 2025 12:12:00 -0700 Subject: [PATCH 1/2] Fix example parsing when there is only 1 example --- .../CommandHelpMarkdownReader.cs | 2 +- .../ImportMarkdownCommandHelp.Tests.ps1 | 6 ++ test/Pester/assets/Get-MPIOSetting.md | 62 +++++++++++++++++++ 3 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 test/Pester/assets/Get-MPIOSetting.md diff --git a/src/MarkdownReader/CommandHelpMarkdownReader.cs b/src/MarkdownReader/CommandHelpMarkdownReader.cs index 73dcf5f3..b6433bdd 100644 --- a/src/MarkdownReader/CommandHelpMarkdownReader.cs +++ b/src/MarkdownReader/CommandHelpMarkdownReader.cs @@ -1056,7 +1056,7 @@ internal static Collection GetExamples(ParsedMarkdownContent mdc, int s var exampleItemIndex = GetNextHeaderIndex(md, expectedHeaderLevel: 3, startIndex: currentIndex); - if (exampleItemIndex > endExampleIndex) + if (exampleItemIndex > endExampleIndex || exampleItemIndex == -1) { break; } diff --git a/test/Pester/ImportMarkdownCommandHelp.Tests.ps1 b/test/Pester/ImportMarkdownCommandHelp.Tests.ps1 index 57b260ee..b1c67028 100644 --- a/test/Pester/ImportMarkdownCommandHelp.Tests.ps1 +++ b/test/Pester/ImportMarkdownCommandHelp.Tests.ps1 @@ -201,6 +201,12 @@ Describe 'Import-MarkdownCommandHelp Tests' { It "Should preserve embedded emphasis in the example title" { $v2ch.Examples[0].Title | Should -Be "Example 1: Get child items from a **file** system directory" } + + It 'Should work if only 1 example is present' { + $ch = Import-MarkdownCommandHelp "$PSScriptRoot/assets/Get-MPIOSetting.md" + $ch.Examples.Count | Should -Be 1 + $ch.Examples[0].Title | Should -Be "Example 1: Get MPIO settings" + } } Context 'Syntax' { diff --git a/test/Pester/assets/Get-MPIOSetting.md b/test/Pester/assets/Get-MPIOSetting.md new file mode 100644 index 00000000..a3ac3b8c --- /dev/null +++ b/test/Pester/assets/Get-MPIOSetting.md @@ -0,0 +1,62 @@ +--- +external help file: MPIO_Cmdlets.xml +Module Name: MPIO +online version: https://learn.microsoft.com/powershell/module/mpio/get-mpiosetting?view=windowsserver2012-ps&wt.mc_id=ps-gethelp +schema: 2.0.0 +title: Get-MPIOSetting +--- +# Get-MPIOSetting + +## SYNOPSIS +Gets MPIO settings. + +## SYNTAX + +``` +Get-MPIOSetting +``` + +## DESCRIPTION +The **Get-MPIOSetting** cmdlet gets Microsoft Multipath I/O (MPIO) settings. +The settings are as follows: + +- PathVerificationState +- PathVerificationPeriod +- PDORemovePeriod +- RetryCount +- RetryInterval +- UseCustomPathRecoveryTime +- CustomPathRecoveryTime +- DiskTimeoutValue + +You can use the **Set-MPIOSetting** cmdlet to change these values. + +## EXAMPLES + +### Example 1: Get MPIO settings +``` +PS C:\>Get-MPIOSetting + +PathVerificationState : Disabled +PathVerificationPeriod : 30 +PDORemovePeriod : 20 +RetryCount : 3 +RetryInterval : 1 +UseCustomPathRecoveryTime : Disabled +CustomPathRecoveryTime : 40 +DiskTimeoutValue : 120 +``` + +This command gets the MPIO settings. + +## PARAMETERS + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS + +[Set-MPIOSetting](./Set-MPIOSetting.md) From cb3bf3358268f475a25e0f1fd31b543be7f7ab35 Mon Sep 17 00:00:00 2001 From: Aditya Patwardhan Date: Mon, 12 May 2025 12:34:19 -0700 Subject: [PATCH 2/2] Fix tests for expected assets --- test/Pester/MeasurePlatyPSMarkdown.Tests.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/Pester/MeasurePlatyPSMarkdown.Tests.ps1 b/test/Pester/MeasurePlatyPSMarkdown.Tests.ps1 index b4be220c..383e312a 100644 --- a/test/Pester/MeasurePlatyPSMarkdown.Tests.ps1 +++ b/test/Pester/MeasurePlatyPSMarkdown.Tests.ps1 @@ -13,9 +13,9 @@ Describe "Export-MarkdownModuleFile" { It "Should identify all the '' assets" -TestCases @( @{ fileType = "unknown"; expectedCount = 2 } - @{ fileType = "CommandHelp"; expectedCount = 37 } + @{ fileType = "CommandHelp"; expectedCount = 38 } @{ fileType = "ModuleFile"; expectedCount = 14 } - @{ fileType = "V1Schema"; expectedCount = 47 } + @{ fileType = "V1Schema"; expectedCount = 48 } @{ fileType = "V2Schema"; expectedCount = 4 } ) { param ($fileType, $expectedCount)