Skip to content

Fix example parsing when there no parameters on the command #741

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/MarkdownReader/CommandHelpMarkdownReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1056,7 +1056,7 @@ internal static Collection<Example> GetExamples(ParsedMarkdownContent mdc, int s

var exampleItemIndex = GetNextHeaderIndex(md, expectedHeaderLevel: 3, startIndex: currentIndex);

if (exampleItemIndex > endExampleIndex)
if (exampleItemIndex > endExampleIndex || exampleItemIndex == -1)
{
break;
}
Expand Down
6 changes: 6 additions & 0 deletions test/Pester/ImportMarkdownCommandHelp.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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' {
Expand Down
4 changes: 2 additions & 2 deletions test/Pester/MeasurePlatyPSMarkdown.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ Describe "Export-MarkdownModuleFile" {

It "Should identify all the '<fileType>' 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)
Expand Down
62 changes: 62 additions & 0 deletions test/Pester/assets/Get-MPIOSetting.md
Original file line number Diff line number Diff line change
@@ -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)