OLD | NEW |
1 # Reflectable | 1 # Reflectable |
2 | 2 |
3 *A listing of known limitations is given at the end of this page.* | 3 *A listing of known limitations is given at the end of this page.* |
4 | 4 |
5 ## Introduction | 5 ## Introduction |
6 | 6 |
7 This package provides support for reflection which may be tailored to cover | 7 This package provides support for reflection which may be tailored to cover |
8 certain reflective features and omit others, thus reducing the resource | 8 certain reflective features and omit others, thus reducing the resource |
9 requirements at runtime. | 9 requirements at runtime. |
10 | 10 |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 dependencies: | 132 dependencies: |
133 reflectable: any | 133 reflectable: any |
134 | 134 |
135 transformers: | 135 transformers: |
136 - reflectable: | 136 - reflectable: |
137 entry_points: | 137 entry_points: |
138 - web/main.dart # The path to your main file | 138 - web/main.dart # The path to your main file |
139 formatted: true # Optional. | 139 formatted: true # Optional. |
140 ``` | 140 ``` |
141 | 141 |
142 Note that it is possible to use globbing with entry points, based on the | 142 Note that it is necessary to include the reflectable transformer in the |
143 package [glob](https://pub.dartlang.org/packages/glob). For instance, | 143 `pubspec.yaml` of your package if you use reflectable directly *or indirectly* |
144 `entry_points: ["test/*_test.dart"]` can be used to specify that all Dart | 144 (by depending on a package that uses reflectable), because the transformer may |
145 source files in `test` whose name ends in `_test.dart` are entry points. | 145 need to generate code based on files in your package. In particular, if you |
| 146 are writing a package which uses reflectable and is expected to be used by |
| 147 clients, please make it explicit that such clients must include the reflectable |
| 148 transformer in their `pubspec.yaml`. |
| 149 |
| 150 It is possible to use globbing with entry points, based on the package |
| 151 [glob](https://pub.dartlang.org/packages/glob). For instance, `entry_points: |
| 152 ["test/*_test.dart"]` can be used to specify that all Dart source files in |
| 153 `test` whose name ends in `_test.dart` are entry points. |
146 | 154 |
147 Now run `pub build --mode=debug web` to perform the transformation. This will | 155 Now run `pub build --mode=debug web` to perform the transformation. This will |
148 rename the file `web/main.dart` and generate a new file `build/web/main.dart`. | 156 rename the file `web/main.dart` and generate a new file `build/web/main.dart`. |
149 That file contains the data needed for reflection, and a main function that | 157 That file contains the data needed for reflection, and a main function that |
150 will initialize the reflection framework before running the original `main`. | 158 will initialize the reflection framework before running the original `main`. |
151 When you run this file, it is important that the package-root is set to | 159 When you run this file, it is important that the package-root is set to |
152 `build/web/packages`, because the reflectable package itself is transformed | 160 `build/web/packages`, because the reflectable package itself is transformed |
153 to a version that uses the generated data, instead of using `dart:mirrors`. | 161 to a version that uses the generated data, instead of using `dart:mirrors`. |
154 | 162 |
155 Some elements in this scenario are optional: In the `pub build..` command, you | 163 Some elements in this scenario are optional: In the `pub build..` command, you |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 | 300 |
293 - The mirror method `libraryDependencies` has not yet been implemented with | 301 - The mirror method `libraryDependencies` has not yet been implemented with |
294 transformed code. | 302 transformed code. |
295 | 303 |
296 ## Feature requests and bug reports | 304 ## Feature requests and bug reports |
297 | 305 |
298 Please file feature requests and bugs using the | 306 Please file feature requests and bugs using the |
299 [github issue tracker for this repository][7]. | 307 [github issue tracker for this repository][7]. |
300 | 308 |
301 [7]: https://github.com/dart-lang/reflectable/issues | 309 [7]: https://github.com/dart-lang/reflectable/issues |
OLD | NEW |