Skip to content

Commit 722fe8d

Browse files
Fix example parsing when there no parameters on the command (#741)
1 parent 0013603 commit 722fe8d

File tree

4 files changed

+71
-3
lines changed

4 files changed

+71
-3
lines changed

src/MarkdownReader/CommandHelpMarkdownReader.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1056,7 +1056,7 @@ internal static Collection<Example> GetExamples(ParsedMarkdownContent mdc, int s
10561056

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

1059-
if (exampleItemIndex > endExampleIndex)
1059+
if (exampleItemIndex > endExampleIndex || exampleItemIndex == -1)
10601060
{
10611061
break;
10621062
}

test/Pester/ImportMarkdownCommandHelp.Tests.ps1

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,12 @@ Describe 'Import-MarkdownCommandHelp Tests' {
201201
It "Should preserve embedded emphasis in the example title" {
202202
$v2ch.Examples[0].Title | Should -Be "Example 1: Get child items from a **file** system directory"
203203
}
204+
205+
It 'Should work if only 1 example is present' {
206+
$ch = Import-MarkdownCommandHelp "$PSScriptRoot/assets/Get-MPIOSetting.md"
207+
$ch.Examples.Count | Should -Be 1
208+
$ch.Examples[0].Title | Should -Be "Example 1: Get MPIO settings"
209+
}
204210
}
205211

206212
Context 'Syntax' {

test/Pester/MeasurePlatyPSMarkdown.Tests.ps1

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

1414
It "Should identify all the '<fileType>' assets" -TestCases @(
1515
@{ fileType = "unknown"; expectedCount = 2 }
16-
@{ fileType = "CommandHelp"; expectedCount = 37 }
16+
@{ fileType = "CommandHelp"; expectedCount = 38 }
1717
@{ fileType = "ModuleFile"; expectedCount = 14 }
18-
@{ fileType = "V1Schema"; expectedCount = 47 }
18+
@{ fileType = "V1Schema"; expectedCount = 48 }
1919
@{ fileType = "V2Schema"; expectedCount = 4 }
2020
) {
2121
param ($fileType, $expectedCount)

test/Pester/assets/Get-MPIOSetting.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
---
2+
external help file: MPIO_Cmdlets.xml
3+
Module Name: MPIO
4+
online version: https://learn.microsoft.com/powershell/module/mpio/get-mpiosetting?view=windowsserver2012-ps&wt.mc_id=ps-gethelp
5+
schema: 2.0.0
6+
title: Get-MPIOSetting
7+
---
8+
# Get-MPIOSetting
9+
10+
## SYNOPSIS
11+
Gets MPIO settings.
12+
13+
## SYNTAX
14+
15+
```
16+
Get-MPIOSetting
17+
```
18+
19+
## DESCRIPTION
20+
The **Get-MPIOSetting** cmdlet gets Microsoft Multipath I/O (MPIO) settings.
21+
The settings are as follows:
22+
23+
- PathVerificationState
24+
- PathVerificationPeriod
25+
- PDORemovePeriod
26+
- RetryCount
27+
- RetryInterval
28+
- UseCustomPathRecoveryTime
29+
- CustomPathRecoveryTime
30+
- DiskTimeoutValue
31+
32+
You can use the **Set-MPIOSetting** cmdlet to change these values.
33+
34+
## EXAMPLES
35+
36+
### Example 1: Get MPIO settings
37+
```
38+
PS C:\>Get-MPIOSetting
39+
40+
PathVerificationState : Disabled
41+
PathVerificationPeriod : 30
42+
PDORemovePeriod : 20
43+
RetryCount : 3
44+
RetryInterval : 1
45+
UseCustomPathRecoveryTime : Disabled
46+
CustomPathRecoveryTime : 40
47+
DiskTimeoutValue : 120
48+
```
49+
50+
This command gets the MPIO settings.
51+
52+
## PARAMETERS
53+
54+
## INPUTS
55+
56+
## OUTPUTS
57+
58+
## NOTES
59+
60+
## RELATED LINKS
61+
62+
[Set-MPIOSetting](./Set-MPIOSetting.md)

0 commit comments

Comments
 (0)