This repository has been archived by the owner on May 28, 2024. It is now read-only.
Add bundle text format specification #9
Labels
epic
This is a very large issue that is composed from smaller more actionable issues
Milestone
It should be possible to write bundle specification files in plain text, instead of dart code. A parser for some text format should be added. The easiest format would be something like YAML (which also support reusing snippets/templates).
Basic functionality
This could be an example bundle:
This would be a pretty 1-to-1 translation from dart types to YAML.
Bundle
is a dictionary with the attributes of theBundle
dart class.rootMenu
espects aMenu
type, so it should be a dictionary of only one element where the key is the type name (as withBundle
, soGridMenu
is the menu type, and the dictionary attributes are the class attributes.buttons
, then each element is a dictionary with one key only and the key is the type of that particular element.So the parser should just read the YAML and delegate to type factories that will decide which type to created based on some string, and this should be propagated all the way down.
Advanced functionality
This approach allows us to then add aliases and default types, to make the syntax much more terse for the most common cases.
The most basic aliases would be just removing the last word for
StyledButton
andPlayContentAction
for example, but it can be taken even further and makePlay
an alias forPlayContentAction
. These aliases are context-sensitive, as we'll only search for types deriving fromAction
when parsing theaction
attribute contents, so it would be easy to avoid name clashes.If a type is defined by a string or list instead of a dictionary, then it can be interpreted as a default attribute or several attributes parsed using a custom parser. For example:
Could be reduced to:
Here the
Image
contents are expected to be a dictionary normally, but if a string is found instead, theresource
attribute is set to that string.If when a type is expected, a dictionary or a list if found instead, then a default type could be used. If a string is found but it doesn't match any type, then it could also fall back. For example this:
Could be written as:
Where the type is assumed to be
GridMenu
and then the attributes are interpreted as usual forGridMenu
. ButGridMenu
could also implement a custom parser to setrows
andcolumns
in a more terse way, likesize: 1x1
.A more complete demonstration:
The text was updated successfully, but these errors were encountered: