Skip to content
This repository was archived by the owner on Apr 8, 2025. It is now read-only.

Commit f7d053c

Browse files
authored
Prepare to publish. (#150)
1 parent dbb52f5 commit f7d053c

File tree

3 files changed

+62
-3
lines changed

3 files changed

+62
-3
lines changed

CHANGELOG.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,63 @@
1+
## 2.0.0
2+
3+
Re-released without a direct dependency on `package:analyzer`!
4+
5+
For users of the `1.x` branch of `code_builder`, this is a pretty big breaking
6+
change but ultimately is for the better - it's easier to evolve this library
7+
now and even add your own builders on top of the library.
8+
9+
```dart
10+
// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
11+
// for details. All rights reserved. Use of this source code is governed by a
12+
// BSD-style license that can be found in the LICENSE file.
13+
14+
import 'package:code_builder/code_builder.dart';
15+
import 'package:dart_style/dart_style.dart';
16+
17+
void main() {
18+
final animal = new Class((b) => b
19+
..name = 'Animal'
20+
..extend = refer('Organism')
21+
..methods.add(new Method.returnsVoid((b) => b
22+
..name = 'eat'
23+
..lambda = true
24+
..body = const Code('print(\'Yum\')'))));
25+
final emitter = new DartEmitter();
26+
print(new DartFormatter().format('${animal.accept(emitter)}'));
27+
}
28+
```
29+
30+
...outputs...
31+
32+
```dart
33+
class Animal extends Organism {
34+
void eat() => print('Yum!');
35+
}
36+
```
37+
38+
**Major changes**:
39+
40+
* Builders now use `built_value`, and have a more consistent, friendly API.
41+
* Builders are now consistent - they don't any work until code is emitted.
42+
* It's possible to overwrite the built-in code emitting, formatting, etc by
43+
providing your own visitors. See `DartEmitter` as an example of the built-in
44+
visitor/emitter.
45+
* Most of the expression and statement level helpers were removed; in practice
46+
they were difficult to write and maintain, and many users commonly asked for
47+
opt-out type APIs. See the `Code` example below:
48+
49+
```dart
50+
void main() {
51+
var code = new Code('x + y = z');
52+
code.expression;
53+
code.statement;
54+
}
55+
```
56+
57+
See the commit log, examples, and tests for full details. While we want to try
58+
and avoid breaking changes, suggestions, new features, and incremental updates
59+
are welcome!
60+
161
## 2.0.0-beta
262

363
* Added `lazySpec` and `lazyCode` to lazily create code on visit [#145](https://github.com/dart-lang/code_builder/issues/145).

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ All submissions, including submissions by project members, require review.
2323
### File headers
2424
All files in the project must start with the following header.
2525

26-
// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
26+
// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
2727
// for details. All rights reserved. Use of this source code is governed by a
2828
// BSD-style license that can be found in the LICENSE file.
2929

pubspec.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: code_builder
2-
version: 2.0.0-beta
2+
version: 2.0.0
33
description: A fluent API for generating Dart code
44
author: Dart Team <[email protected]>
55
homepage: https://github.com/dart-lang/code_builder
@@ -17,6 +17,5 @@ dependencies:
1717
dev_dependencies:
1818
build_runner: '>=0.4.0 <0.6.0'
1919
built_value_generator: '>=2.0.0 <5.0.0'
20-
io: '>=0.1.0 <0.3.0'
2120
source_gen: '^0.7.0'
2221
test: ^0.12.0

0 commit comments

Comments
 (0)