syntaxify 0.1.0-alpha.1
syntaxify: ^0.1.0-alpha.1 copied to clipboard
AST-based Flutter UI code generator with multi-style design system. Write components once, render in Material, Cupertino, or custom designs.
Syntaxify Generator π¨ #
A powerful CLI tool that generates production-ready, type-safe Flutter widgets from "Meta" definitions and Design Tokens.
π Getting Started #
1. Add Dependency #
Add Syntaxify to your project:
dev_dependencies:
syntaxify:
git:
url: https://github.com/ihardk/syntaxify.git
ref: v0.1.0
path: generator
2. Initialize Project #
Scaffold the required directories:
syntaxify init
Note: If you skip this step, syntaxify build will detect missing files and ask to initialize for you.
3. Build Components #
Generate your Flutter widgets:
syntaxify build
π§ For Contributors #
Run from source (in generator directory):
dart run bin/syntaxify.dart build
π± Update Example App #
To regenerate the example app (from root):
cd example
syntaxify build
π» CLI Commands #
build #
Generates Flutter widgets.
| Option | Alias | Default | Description |
|---|---|---|---|
--output |
-o |
lib/syntaxify |
Output directory for generated code |
--meta |
-m |
meta |
Directory containing user definitions (.meta.dart) |
--tokens |
design_system |
Directory containing token files | |
--component |
-c |
All | Build only a specific component (e.g., AppButton) |
--theme |
-t |
All | Build only a specific theme (e.g., material) |
clean #
Removes generated artifacts.
| Option | Alias | Default | Description |
|---|---|---|---|
--output |
-o |
lib/syntaxify |
Directory to clean |
πΊοΈ Codebase Walkthrough #
The generator follows a SOLID, 5-layer architecture. Here is how to navigate the code:
1. π CLI Layer (lib/src/cli/) #
Entry point for all commands.
build_command.dart: Parses arguments (output dir, flags) and orchestrates the build.clean_command.dart: Logic for removing files.
2. π§ Use Cases (lib/src/use_cases/) #
High-level business logic.
build_all.dart: The main director. It coordinates reading tokens, generating components, and copying design system files.generate_component_usecase.dart: The logic to build a single component.
3. π§© Generators (lib/src/generators/) #
Visual rendering logic (The "Renderer" Pattern).
component/: Separate class for each widget (e.g.,ButtonGenerator,CardGenerator).generator_registry.dart: Factory that maps a component name ('button') to its generator (ButtonGenerator).
4. π§± Core (lib/src/core/) #
Domain entities and interfaces.
models/: Data structures likeMetaComponent(parsed input) andTokenDefinition.interfaces/: Contracts forFileSystem,Parser, etc.
5. π Infrastructure (lib/src/infrastructure/) #
Low-level implementations.
file_system_impl.dart: Real disk I/O.parsers/: Logic to parse.meta.dartfiles (usinganalyzerpackage).
π§ How it Works (The Flow) #
- Parse:
MetaParserreadsmeta/button.meta.dart-> createsMetaComponentmodel. - Lookup:
GeneratorRegistryfindsButtonGenerator. - Generate:
ButtonGeneratorproduces Dart code strings (imports, class definition,buildmethod). - Write:
BuildAllUseCasewrites the file tolib/syntaxify/generated/components/app_button.dart.
π Key Directories #
| Path | Purpose |
|---|---|
bin/syntaxify.dart |
Main Entrypoint. Run this to start. |
design_system/ |
Templates. Files copied directly to user project (e.g. app_theme.dart). |
lib/src/generators/component/ |
Widget Logic. Edit these files to change how widgets look. |