Skip to content

Import-MarkdownCommandHelp improperly parses when descriptions are missing #723

Open
@sdwheeler

Description

@sdwheeler

Prerequisites

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

Steps to reproduce

Compare-CommandHelp.md

PS> $c = Import-MarkdownCommandHelp -Path .\v2\Microsoft.PowerShell.PlatyPS\Compare-CommandHelp.md
PS> $c | select *

Metadata                    : {[document type, cmdlet], [external help file, Microsoft.PowerShell.PlatyPS.dll-Help.xml], [HelpUri, ], [Locale, en-US]…}
Locale                      : en-US
ModuleGuid                  : 
ExternalHelpFile            : 
OnlineVersionUrl            : 
SchemaVersion               : 
ModuleName                  : Microsoft.PowerShell.PlatyPS
Title                       : Compare-CommandHelp
Synopsis                    : 
Syntax                      : {}
AliasHeaderFound            : True
Aliases                     : This cmdlet has the following aliases,
                              
Description                 : ## EXAMPLES
                              
                              ### Example 1
Examples                    : {Microsoft.PowerShell.PlatyPS.Model.Example}
Parameters                  : {DifferenceCommandHelp, PropertyNamesToExclude, ReferenceCommandHelp}
Inputs                      : {Microsoft.PowerShell.PlatyPS.Model.CommandHelp}
Outputs                     : {System.String}
Notes                       : 
RelatedLinks                : {}
HasCmdletBinding            : True
HasWorkflowCommonParameters : False
Diagnostics                 : Microsoft.PowerShell.PlatyPS.Model.Diagnostics

Expected behavior

Import should be able to parse each section of the markdown and assign null values to the description values in each section.

Actual behavior

As you can see from the output, when SYNOPSIS is empty the syntax isn't found. Also, the Description property contain the EXAMPLE text when it should be empty. Depending which section is missing a description, errors cascade from there. In this example, the diagnostic data shows errors, but that doesn't always occur depending on what is missing.

See the attached file that I used to test.

Error details

PS> $c.Diagnostics.Messages

Source      Severity    Message                           Identifier                      Line
------      --------    -------                           ----------                      ----
Metadata    Information {Metadata}                        found 'external help file'      1
Metadata    Information {Metadata}                        found 'Locale'                  1
Metadata    Information {Metadata}                        found 'Module Name'             1
Metadata    Information {Metadata}                        found 'ms.date'                 1
Metadata    Information {Metadata}                        found 'HelpUri'                 1
Metadata    Information {Metadata}                        found 'PlatyPS schema version'  1
Metadata    Information {Metadata}                        found 'title'                   1
General     Information {CmdletBinding is present}        GetCmdletBindingState           97
General     Information {Workflow parameters not present} GetWorkflowCommonParameterState -1
Synopsis    Information {SYNOPSIS found}                                                  14
Synopsis    Error       {SYNOPSIS found}                  Synopsis text is empty          14
Syntax      Error       {SYNTAX header not found}         missing syntax                  -1
Alias       Information {ALIASES header found}            alias header is AST 7           25
Alias       Information {Alias string length}             alias string length: 39         27
Description Information {DESCRIPTION header found}        DESCRIPTION                     29
Example     Information {EXAMPLES header found}           1 examples found                31
Parameter   Information {Parameters}                      3 parameters found              12
Parameter   Information {DifferenceCommandHelp found}     Version 2 metadata found        37
Parameter   Information {PropertyNamesToExclude found}    Version 2 metadata found        57
Parameter   Information {ReferenceCommandHelp found}      Version 2 metadata found        77
Parameter   Information {CommonParameters found}          GetParameters                   79
Inputs      Information {GetInput}                        1 items found                   21
Outputs     Information {GetOutput}                       1 items found                   23
Notes       Warning     {Notes content not found}         GetNotes                        112
Links       Warning     {no links found}                  GetRelatedLinks                 114

Environment data

I used the latest build from Aditya.

Visuals

No response

Metadata

Metadata

Labels

Needs-TriageThe issue is new and needs to be triaged by a work group.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions