platyPS
platyPS copied to clipboard
What is considered a default value?
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?
I want this feature too. I don't think there is a way to discover the default value through reflection. This needs further investigation.
My understand is that the PSDefaultValue attribute is supposed to do this:
However, testing with PlatyPS 0.14.2 -- it doesn't work.
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.