Open tolyo opened 1 year ago
Thanks for filing this issue; I'd love to see this! The right direction for enumerated attributes would probably be to create an enum per attribute derived from the spec, and then provide that next to the element.
The right first step would probably be to start scraping and normalizing the attributes so we can update the JSON. And then in a follow-up PR work on introducing the codegen.
Awesome. So assuming we take dir
element for example, what should be our format? I am assuming enums
are always strings (???) and they can be hypen-separated (???). Need to double check but we can go with:
{
"name": "dir",
"description": "Indicates the directionality of the element's text with enumerated type",
"field_name": "direction",
"ty": "Enum{ltr, rtl, auto}"
}
or
...
"ty": "Enum",
"values": ["ltr", "rtl", "auto"]
I'm not sure how to parse enums either, so you'll have to look into that. But starting with the assumption that they're always strings is probably a safe one?
In terms of formats: the second one would be preferable over the first, since it seems easier to generate/parse using serde.
Looking at the global attributes spec, we have only three types:
String
,Integer
, andBool
. For theString
type, what would be the strategy to support enumerated attributes?