Skip to content

Commit

Permalink
Bug fixes and enhancements for default value determination in ARM docs
Browse files Browse the repository at this point in the history
Use table-based output format for parameter metadata
  • Loading branch information
SvenAelterman committed Dec 28, 2024
1 parent add27f5 commit a085269
Show file tree
Hide file tree
Showing 3 changed files with 229 additions and 72 deletions.
53 changes: 46 additions & 7 deletions research-spoke/ResearchSpoke.Doc.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,26 @@ function global:GetTemplateParameter {
$template = Get-Content $Path | ConvertFrom-Json;
foreach ($property in $template.parameters.PSObject.Properties) {
[PSCustomObject]@{
Name = $property.Name
Description = $property.Value.metadata.description
Type = $property.Value.type
Required = !("defaultValue" -in $property.Value.PSObject.Properties.Name -or $property.Value.nullable)
DefaultValue = $property.Value.defaultValue
Name = $property.Name
Description = $property.Value.metadata.description
Type = $property.Value.type
Required = !("defaultValue" -in $property.Value.PSObject.Properties.Name -or $property.Value.nullable)
DefaultValue = if ("defaultValue" -in $property.Value.PSObject.Properties.Name) {
if ($property.Value.defaultValue) { $property.Value.defaultValue } else {
switch ($property.Value.type) {
'string' { '''''' }
'object' { '{ }' }
'array' { '()' }
'bool' { 'false' }
'securestring' { '''''' }
}
}
}
AllowedValues = if ($property.Value.allowedValues) {
"``$($property.Value.allowedValues -join '`, `')``"
}
MinLength = $property.Value.minLength
MaxLength = $property.Value.maxLength
}
}
}
Expand Down Expand Up @@ -86,9 +101,33 @@ Document Research-Spoke {
"![Parameter Setting](https://img.shields.io/badge/parameter-optional-green?style=flat-square)"
}
$_.Description
$Details = "- Type: ``$($_.Type)``"
# $Details = "- Type: ``$($_.Type)``"
# if ($_.DefaultValue) {
# $Details += "`n- Default value: ``$($_.DefaultValue)``"
# }
# if ($_.AllowedValues) {
# $Details += "`n- Allowed values: $($_.AllowedValues)"
# }
# if ($_.MinLength) {
# $Details += "`n- Minimum length: $($_.MinLength)"
# }
# if ($_.MaxLength) {
# $Details += "`n- Maximum length: $($_.MaxLength)"
# }
# $Details

$Details = "Metadata | Value`n---- | ----`nType | $($_.Type)"
if ($_.DefaultValue) {
$Details += "`n- Default value: ``$($_.DefaultValue)``"
$Details += "`nDefault value | ``$($_.DefaultValue)``"
}
if ($_.AllowedValues) {
$Details += "`nAllowed values | $($_.AllowedValues)"
}
if ($_.MinLength) {
$Details += "`nMinimum length | $($_.MinLength)"
}
if ($_.MaxLength) {
$Details += "`nMaximum length | $($_.MaxLength)"
}
$Details
}
Expand Down
Loading

0 comments on commit a085269

Please sign in to comment.