[material_ui] Set up m3e_gen_defaults sub-directory#11762
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a new 'Token Defaults Generator' tool in the material_ui package, consisting of a command-line script, a base template class for code generation, and unit tests. Review feedback identifies a discrepancy between the documented and implemented output paths, a typo in the SDK version constraint which is incompatible with the workspace resolution feature, and a potential runtime error when creating files in non-existent directories.
|
Do you think whether naming the folder |
QuncCccccc
left a comment
There was a problem hiding this comment.
Overall LGTM! Just left some comments.
| version: 1.0.0 | ||
|
|
||
| environment: | ||
| sdk: ^3.10.0-0 |
There was a problem hiding this comment.
I'm actually not familiar with how to constrain the version. In packages/material_ui/pubspec.yaml, it shows sdk: ^3.9.0, do we need to match it?
There was a problem hiding this comment.
oh but seems material_ui/example also use sdk: ^3.10.0-0
| @@ -0,0 +1,15 @@ | |||
| name: gen_defaults | |||
| description: A command line script to generate Material component defaults from the token database. | |||
There was a problem hiding this comment.
Should we also make it not publishable? like material_ui/example.
| description: A command line script to generate Material component defaults from the token database. | |
| description: A command line script to generate Material component defaults from the token database. | |
| publish_to: none |
| ``` | ||
|
|
||
| This updates generated component theming files under | ||
| `packages/material_ui/lib/src/m3e/generated`. |
There was a problem hiding this comment.
The new folder for m3e should not contain abbreviation based on the style guide.
| `packages/material_ui/lib/src/m3e/generated`. | |
| `packages/material_ui/lib/src/material_3_expressive/generated`. |
|
|
||
| String get materialLib { | ||
| const packagePath = 'packages/material_ui'; | ||
| const relativeOutputPath = 'lib/src/m3e/generated'; |
There was a problem hiding this comment.
| const relativeOutputPath = 'lib/src/m3e/generated'; | |
| const relativeOutputPath = 'lib/src/material_3_expressive/generated'; |
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| abstract final class TokenButton { |
There was a problem hiding this comment.
Just to match the real generated token file
| abstract final class TokenButton { | |
| class TokenButton { |
| // Design token database by the script: | ||
| // packages/material_ui/tool/m3e_gen_defaults/bin/gen_defaults.dart. | ||
|
|
||
| // dart format off |
There was a problem hiding this comment.
Maybe we should remove this and keep the format correct, even though it's just generated code. I vaguely remember this line is added when we started to use dart format and wanted to avoid updating these code that are already generated. But for expressive, maybe we can consider to allow dart format?
Work towards flutter/flutter#186906
Adds the initial
gen_defaultssub-directory with the initialTokenTemplateand generator. This is simply the initial scaffold, we will need to add additional helper functions as necessary as we begin adding the actual templates.Pre-Review Checklist
[shared_preferences]///).If you need help, consider asking for advice on the #hackers-new channel on Discord.
Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the
gemini-code-assistbot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.Footnotes
Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. ↩ ↩2