Skip to content

Commit 5bb388b

Browse files
authored
Move over example and tool directories (#4)
1 parent 0ace5c5 commit 5bb388b

File tree

6 files changed

+185
-0
lines changed

6 files changed

+185
-0
lines changed

example/data.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"glossary":{"title":"example glossary","GlossDiv":{"title":"S","GlossList":{"GlossEntry":{"ID":"SGML","SortAs":"SGML","GlossTerm":"Standard Generalized Markup Language","Acronym":"SGML","Abbrev":"ISO 8879:1986","GlossDef":{"para":"A meta-markup language, used to create markup languages such as DocBook.","GlossSeeAlso":["GML","XML"]},"GlossSee":"markup"}}}}}

example/example.dart

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
library source_gen.example.example;
6+
7+
import 'package:source_gen/generators/json_serializable.dart';
8+
import 'package:source_gen/generators/json_literal.dart';
9+
10+
part 'example.g.dart';
11+
12+
@JsonSerializable()
13+
class Person extends Object with _$PersonSerializerMixin {
14+
final String firstName, middleName, lastName;
15+
16+
@JsonKey('date-of-birth')
17+
final DateTime dateOfBirth;
18+
List<Order> orders;
19+
20+
Person(this.firstName, this.lastName, {this.middleName, this.dateOfBirth});
21+
22+
factory Person.fromJson(json) => _$PersonFromJson(json);
23+
}
24+
25+
@JsonSerializable()
26+
class Order extends Object with _$OrderSerializerMixin {
27+
int count;
28+
int itemNumber;
29+
bool isRushed;
30+
Item item;
31+
32+
Order();
33+
34+
factory Order.fromJson(json) => _$OrderFromJson(json);
35+
}
36+
37+
@JsonSerializable(createToJson: false)
38+
class Item {
39+
int count;
40+
int itemNumber;
41+
bool isRushed;
42+
43+
Item();
44+
45+
factory Item.fromJson(json) => _$ItemFromJson(json);
46+
}
47+
48+
@JsonLiteral('data.json')
49+
Map get glossaryData => _$glossaryDataJsonLiteral;

example/example.g.dart

Lines changed: 96 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tool/build.dart

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
import 'package:build_runner/build_runner.dart';
6+
7+
import 'phases.dart';
8+
9+
main() async {
10+
await build(phases, deleteFilesByDefault: true);
11+
}

tool/phases.dart

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
import 'package:build_runner/build_runner.dart';
6+
7+
import 'package:source_gen/generators/json_literal_generator.dart' as literal;
8+
import 'package:source_gen/generators/json_serializable_generator.dart' as json;
9+
import 'package:source_gen/source_gen.dart';
10+
11+
final PhaseGroup phases = new PhaseGroup.singleAction(
12+
new GeneratorBuilder(const [
13+
const json.JsonSerializableGenerator(),
14+
const literal.JsonLiteralGenerator()
15+
]),
16+
new InputSet('source_gen',
17+
const ['example/*.dart', 'test/test_files/json_test_example.dart']));

tool/watch.dart

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
import 'package:build_runner/build_runner.dart';
6+
7+
import 'phases.dart';
8+
9+
main() {
10+
watch(phases, deleteFilesByDefault: true);
11+
}

0 commit comments

Comments
 (0)