Skip to content
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

Import-MarkdownCommandHelp improperly parses when descriptions are missing #723

Open
3 tasks done
sdwheeler opened this issue Mar 7, 2025 · 0 comments
Open
3 tasks done
Labels
Needs-Triage The issue is new and needs to be triaged by a work group.

Comments

@sdwheeler
Copy link
Collaborator

sdwheeler commented Mar 7, 2025

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

@sdwheeler sdwheeler added the Needs-Triage The issue is new and needs to be triaged by a work group. label Mar 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs-Triage The issue is new and needs to be triaged by a work group.
Projects
None yet
Development

No branches or pull requests

1 participant