Skip to content

Commit

Permalink
moved aliases into a separate section in the definition.json
Browse files Browse the repository at this point in the history
  • Loading branch information
jaytaph committed Aug 18, 2024
1 parent 5a4c35c commit 5c1a631
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 20 deletions.
36 changes: 20 additions & 16 deletions crates/gosub_styling/tools/generate_definitions/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,23 +47,9 @@ func main() {
})

for _, property := range webrefData.Properties {

if property.Syntax == "" {
alias, err := webref.GetAlias(property.Name)
if err != nil {
log.Panic("failed to get alias syntax for property: " + property.Name)
}

for wdp := range webrefData.Properties {
if webrefData.Properties[wdp].Name == alias {
property.Syntax = webrefData.Properties[wdp].Syntax
break
}
}

if property.Syntax == "" {
log.Panic("failed to get alias syntax for property: " + property.Name)
}
// Skip any empty syntax, as they will be filled later with alias table
continue
}

prop := utils.Property{
Expand Down Expand Up @@ -124,6 +110,23 @@ func main() {
Descriptors: descriptors,
Values: atRule.Values,
})

for _, property := range webrefData.Properties {
if property.Syntax != "" {
// Skip properties with syntax
continue
}

alias, err := webref.GetAlias(property.Name)
if err != nil {
log.Panic("failed to get alias syntax for property: " + property.Name)
}

data.PropAliases = append(data.PropAliases, utils.PropAlias{
Name: property.Name,
For: alias,
})
}
}

data.Selectors = webrefData.Selectors
Expand Down Expand Up @@ -164,6 +167,7 @@ func ExportMultiFile(data *utils.Data) {
ExportData(data.Values, path.Join(MultiFileDir, MultiFilePrefix+"values.json"))
ExportData(data.AtRules, path.Join(MultiFileDir, MultiFilePrefix+"at-rules.json"))
ExportData(data.Selectors, path.Join(MultiFileDir, MultiFilePrefix+"selectors.json"))
ExportData(data.PropAliases, path.Join(MultiFileDir, MultiFilePrefix+"prop-aliases.json"))

}

Expand Down
14 changes: 10 additions & 4 deletions crates/gosub_styling/tools/generate_definitions/utils/types.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
package utils

type Data struct {
Properties []Property `json:"properties"`
Values []Value `json:"values"`
AtRules []AtRule `json:"atrules"`
Selectors []Selector `json:"selectors"`
Properties []Property `json:"properties"`
Values []Value `json:"values"`
AtRules []AtRule `json:"atrules"`
Selectors []Selector `json:"selectors"`
PropAliases []PropAlias `json:"propAliases"`
}

type PropAlias struct {
Name string `json:"name"`
For string `json:"for"`
}

type Value struct {
Expand Down

0 comments on commit 5c1a631

Please sign in to comment.