platyPS icon indicating copy to clipboard operation
platyPS copied to clipboard

Update-MarkdownHelpModule always adds [<CommonParameters>] to Syntax even when [CmdletBinding()] is not there

Open PrzemyslawKlys opened this issue 6 years ago • 4 comments

I have following function (one of many). It doesn't have [CmdletBinding()].

function New-HTMLAnchor {
    <#
    .SYNOPSIS
    Short description

    .DESCRIPTION
    Long description

    .PARAMETER Name
    Parameter description

    .PARAMETER Target
    Target options: "_blank|_self|_parent|_top|framename"

    .PARAMETER Class

    .PARAMETER HrefLink
    Parameter description

    .PARAMETER Text
    Parameter description

    .EXAMPLE
    New-HTMLAnchor -Target _parent

    Output:
    <a target = "_parent" />

    .NOTES
    General notes
    #>

    param(
        [alias('AnchorName')][string] $Name,
        [string] $Target,
        [string] $Class,
        [alias('Url', 'Link', 'UrlLink')][string] $HrefLink,
        [alias('AnchorText')][string] $Text
    )
    [System.Collections.IDictionary] $Anchor = [Ordered] @{
        Tag        = 'a'
        Attributes = [ordered]@{
            'name'   = $Name
            'class'  = $Class
            'target' = $Target
            'href'   = $HrefLink
        }
        Value      = $Text # if value is blank it will not be used
    }
    $HTML = Set-Tag -HtmlObject $Anchor
    return $HTML
}

Steps to reproduce

  1. New-MarkdownHelp -Module $ProjectName -WithModulePage -OutputFolder $DocumentationPath -ModulePagePath $ReadMePath
  2. Verify output - common parameters will not be there in Syntax and ### CommonParameters will not be there either
  3. Update-MarkdownHelpModule $DocumentationPath -RefreshModulePage -ModulePagePath $ReadMePath
  4. Verify output - common parameters are added in Syntax and whole section ###ComonParameters is added

Expected behavior

Update-MarkdownHelpModule should behave the same way as New-MarkdownHelp

Actual behavior

Adds common parameters regardless if those are there or not.

Environment data

v0.12.0

I saw this: https://github.com/PowerShell/platyPS/issues/223 but even thou I use the newest published version the problem occurs. So it's either incomplete or I am missing something.

PrzemyslawKlys avatar Jan 22 '19 10:01 PrzemyslawKlys

@BernieWhite do you know from the top of your head, how we may regress after #323 is merged?

vors avatar Jan 27 '19 00:01 vors

I just encountered this as well, glad it's already logged.

LethiferousMoose avatar Mar 11 '20 04:03 LethiferousMoose

@vors sorry missed this one. Let me have a look.

BernieWhite avatar Mar 11 '20 07:03 BernieWhite

Verified this is still a bug in 0.14.1

sdwheeler avatar Jun 08 '21 19:06 sdwheeler

This is fixed in the data model used by Microsoft.PowerShell.PlatyPS v1.

sdwheeler avatar May 31 '24 17:05 sdwheeler