platyPS icon indicating copy to clipboard operation
platyPS copied to clipboard

What is considered a default value?

Open chscott opened this issue 4 years ago • 2 comments

I think this is probably a misunderstanding on my part, so I'm not calling this a bug. Here's the function definition for which I am generating doc:

function Get-License {
  [CmdletBinding()]
  Param(
    [Parameter(Mandatory, Position = 0)][String] $LicenseKey,
    [Parameter()][ValidateSet('Csv', 'Json', 'Objects')][String] $Format = 'Objects'
  )

Here's a portion of the generated markdown:

Type: String
Parameter Sets: (All)
Aliases:
Accepted values: Csv, Json, Objects

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

The function has a default value of 'Objects' for the $Format parameter, but the generated doc has Default value: None. What constitutes a default value from the perspective of platyPS?

chscott avatar Nov 23 '20 18:11 chscott

I want this feature too. I don't think there is a way to discover the default value through reflection. This needs further investigation.

sdwheeler avatar Jan 22 '21 18:01 sdwheeler

My understand is that the PSDefaultValue attribute is supposed to do this: image However, testing with PlatyPS 0.14.2 -- it doesn't work.

mithrandyr avatar Dec 09 '23 20:12 mithrandyr

PlatyPS has always support discovery of PSDefaultValue. The problem is that no one includes that attribute on their commands. None of the commands that ship with PowerShell have PSDefaultValue attribute. If you create your own commands with parameters that have PSDefaultValue, PlatyPS will report the value.

sdwheeler avatar May 31 '24 15:05 sdwheeler