diff --git a/src/platyPS/platyPS.psm1 b/src/platyPS/platyPS.psm1 index 54f9d48c..77712d54 100644 --- a/src/platyPS/platyPS.psm1 +++ b/src/platyPS/platyPS.psm1 @@ -210,7 +210,12 @@ function New-MarkdownHelp # Get-Command requires that script input be a path if ($mamlObject.Name.EndsWith(".ps1")) { - $getCommandName = Resolve-Path $Command + if (Test-Path "function:\$(Split-Path $Command -Leaf)") { + $getCommandName = $(Split-Path $Command -Leaf) + } + else { + $getCommandName = Resolve-Path $Command + } } # For cmdlets, nothing needs to be done else @@ -2353,19 +2358,33 @@ function GetMamlObject [switch]$ExcludeDontShow ) - function CommandHasAutogeneratedSynopsis - { - param([object]$help) - - return (Get-Command $help.Name -Syntax) -eq ($help.Synopsis) + function CommandHasAutogeneratedSynopsis { + param( + [parameter(Mandatory = $true, Position = 0)] + [object]$help, + [parameter(mandatory = $false, Position = 1)] + [allowEmptyString()] + [allownull()] + [string]$cmdlet) + $resultValue = $false + if ($null -ne $cmdlet) { + if ($cmdlet -match '\.ps1' -and (-not (Test-Path "function:\$(Split-Path $cmdlet -Leaf)"))) { + $resultValue = (Get-Command $cmdlet -Syntax) -eq ($help.Synopsis) + } + else { + $resultValue = (Get-Command $help.Name -Syntax) -eq ($help.Synopsis) + } + } + else { + $resultValue = (Get-Command $help.Name -Syntax) -eq ($help.Synopsis) + } + return $resultValue } - - if($Cmdlet) - { + if ($Cmdlet) { Write-Verbose -Message ($LocalizedData.Processing -f $Cmdlet) $Help = Get-Help $Cmdlet $Command = MyGetCommand -Session $Session -Cmdlet $Cmdlet - return ConvertPsObjectsToMamlModel -Command $Command -Help $Help -UsePlaceholderForSynopsis:(CommandHasAutogeneratedSynopsis $Help) -UseFullTypeName:$UseFullTypeName -ExcludeDontShow:$ExcludeDontShow + return ConvertPsObjectsToMamlModel -Command $Command -Help $Help -UsePlaceholderForSynopsis:(CommandHasAutogeneratedSynopsis $Help $Cmdlet) -UseFullTypeName:$UseFullTypeName -ExcludeDontShow:$ExcludeDontShow } elseif ($Module) {