Skip to content

Parameter parsing depends on elements after the parameter section #841

@MartinGC94

Description

@MartinGC94

Prerequisites

  • Write a descriptive title.
  • Make sure you are able to repro it on the latest version
  • Search the existing issues.

Steps to reproduce

1: Define a function like this:

function Test-Docs
{
    Param
    (
        [Parameter()]
        [string[]]
        $Param1
    )
}

2: Create markdown help for it: New-MarkdownCommandHelp -CommandInfo (Get-Command Test-Docs) -OutputFolder $HOME

3: Validate that the parameters are found with the diagnostics data:

PS C:\Windows\System32> (Import-MarkdownCommandHelp $HOME\Test-Docs.md).Diagnostics

Diagnostic Output
  File: C:\Users\Martin\Test-Docs.md
  HadErrors: False

Messages:
  Information  Metadata               found 'external help file'
  Information  Metadata               found 'Locale'
  Information  Metadata               found 'Module Name'
  Information  Metadata               found 'ms.date'
  Information  Metadata               found 'HelpUri'
  Information  Metadata               found 'PlatyPS schema version'
  Information  Metadata               found 'title'
  Information  General                GetCmdletBindingState
  Information  General                GetWorkflowCommonParameterState
  Information  Synopsis               SYNOPSIS found
  Information  Syntax                 Test-Docs [[-Param1] <string[]>] [<CommonParameters>]
  Information  Alias                  alias header is AST 8
  Information  Alias                  alias string length: 0
  Information  Description            DESCRIPTION
  Information  Example                1 examples found
  Information  Parameter              1 parameters found
  Information  Parameter              Version 2 metadata found
  Information  Parameter              GetParameters
  Information  Inputs                 0 items found
  Information  Outputs                1 items found
  Information  Notes                  Notes length = 23
  Information  Links                  GetRelatedLinks
  Information  Links                  0 links found

4: Edit the file and delete these sections at the end of the file:

## INPUTS

## OUTPUTS

### System.Object

{{ Fill in the Description }}

## NOTES

{{ Fill in the Notes }}

## RELATED LINKS

{{ Fill in the related links here }}

5: Rerun the validation and note how it now found 0 parameters:

PS C:\Windows\System32> (Import-MarkdownCommandHelp $HOME\Test-Docs.md).Diagnostics

Diagnostic Output
  File: C:\Users\Martin\Test-Docs.md
  HadErrors: True

Messages:
  Information  Metadata               found 'external help file'
  Information  Metadata               found 'Locale'
  Information  Metadata               found 'Module Name'
  Information  Metadata               found 'ms.date'
  Information  Metadata               found 'HelpUri'
  Information  Metadata               found 'PlatyPS schema version'
  Information  Metadata               found 'title'
  Information  General                GetCmdletBindingState
  Information  General                GetWorkflowCommonParameterState
  Information  Synopsis               SYNOPSIS found
  Information  Syntax                 Test-Docs [[-Param1] <string[]>] [<CommonParameters>]
  Information  Alias                  alias header is AST 8
  Information  Alias                  alias string length: 0
  Information  Description            DESCRIPTION
  Information  Example                1 examples found
  Information  Parameter              0 parameters found
  Error        Inputs                 INPUTS header not found
  Error        Inputs                 OUTPUTS header not found
  Error        Notes                  GetNotes
  Warning      Links                  GetRelatedLinks

Expected behavior

Parameters are found and processed even if there's no section defined below them.

Actual behavior

Parameters are not processed unless the document includes a section below the parameters.

Error details

Environment data

Name                           Value
----                           -----
PSVersion                      7.6.0-preview.5
PSEdition                      Core
GitCommitId                    7.6.0-preview.5
OS                             Microsoft Windows 10.0.26200
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.4
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Version

1.0.1

Visuals

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions