Skip to content

Commit

Permalink
fix: MDN Refactor - Fixing Parameter Name Case ( Fixes #218 )
Browse files Browse the repository at this point in the history
also supporting known aliases
  • Loading branch information
James Brundage committed Jul 5, 2024
1 parent 457658d commit 075aa9a
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions Build/PSSVG.Build.ps.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ switch -regex ($svgAttributesByCategory) {
}) | Out-TypeData -OutputPath (Join-Path $pwd "SVG.Attribute.Types.ps1xml")



# If we don't know the list of elements
if (-not $svgElements) {
# we can go to the repo and get the JSON.
Expand All @@ -252,6 +253,16 @@ $replaceMDNContent = "\{\{\s{0,}(?>$(@('Glossary', 'cssxref', 'domxref', 'HTTPMe
'["''](?<s>[^"'']+)["'']\)\s{0,}\}\}'


filter AttributeName=>ParameterName {
$attrName = $_
$attrName = $attrName.Substring(0,1).ToUpper() + $attrName.Substring(1)
[regex]::Replace($attrName, '\W(?<w>\w+)', {
param($match)
$match.Groups['w'].Value.Substring(0,1).ToUpper() +
$match.Groups['w'].Value.Substring(1)
})
}

function ConvertSVGMetadataToParameterAttribute {
param([Parameter(ValueFromPipeline,Position=0)][string]$EdiValue)
$hadNumbers = $false
Expand Down Expand Up @@ -952,17 +963,20 @@ If nothing was provided, each output will be decorated with it's ElementName.
}
)

# Add any missing parameters.
foreach ($potentiallyMissing in $checkForTheseParameters) {
$potentiallyMissingParameterName = $potentiallyMissing.Substring(0,1).ToUpper() + $potentiallyMissing.Substring(1)
$potentiallyMissingParameterName = $potentiallyMissingParameterName -replace '\W'
$potentiallyMissingParameterName = $potentiallyMissing | AttributeName=>ParameterName
if (-not $parameters[$potentiallyMissingParameterName]) {
$parameters[$potentiallyMissing] = @(
"# The $potentiallyMissing attribute. See [MDN](https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/$potentiallyMissing) for more information."
"# The $potentiallyMissing attribute. See [MDN]($svgAttributeLink) for more information."
"[Parameter(ValueFromPipelineByPropertyName)]"
if ($attributeFileData[$potentiallyMissing].IsDeprecated) {
"[Reflection.AssemblyMetaData('SVG.Deprecated',`$true)]"
}
}
"[Reflection.AssemblyMetaData('SVG.AttributeName','$potentiallyMissing')]"
if ($knownParameterAliases[$potentiallyMissingParameterName]) {
"[Alias('$($knownParameterAliases[$potentiallyMissingParameterName] -replace "'", "''" -join "','")')]"
}
"[PSObject]"
"`$$potentiallyMissingParameterName"
)
Expand Down

0 comments on commit 075aa9a

Please sign in to comment.