diff --git a/CHANGELOG.md b/CHANGELOG.md index a11fe37..76ca9b5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,63 @@ +## 2.0.0 + +Re-released without a direct dependency on `package:analyzer`! + +For users of the `1.x` branch of `code_builder`, this is a pretty big breaking +change but ultimately is for the better - it's easier to evolve this library +now and even add your own builders on top of the library. + +```dart +// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'package:code_builder/code_builder.dart'; +import 'package:dart_style/dart_style.dart'; + +void main() { + final animal = new Class((b) => b + ..name = 'Animal' + ..extend = refer('Organism') + ..methods.add(new Method.returnsVoid((b) => b + ..name = 'eat' + ..lambda = true + ..body = const Code('print(\'Yum\')')))); + final emitter = new DartEmitter(); + print(new DartFormatter().format('${animal.accept(emitter)}')); +} +``` + +...outputs... + +```dart +class Animal extends Organism { + void eat() => print('Yum!'); +} +``` + +**Major changes**: + +* Builders now use `built_value`, and have a more consistent, friendly API. +* Builders are now consistent - they don't any work until code is emitted. +* It's possible to overwrite the built-in code emitting, formatting, etc by + providing your own visitors. See `DartEmitter` as an example of the built-in + visitor/emitter. +* Most of the expression and statement level helpers were removed; in practice + they were difficult to write and maintain, and many users commonly asked for + opt-out type APIs. See the `Code` example below: + +```dart +void main() { + var code = new Code('x + y = z'); + code.expression; + code.statement; +} +``` + +See the commit log, examples, and tests for full details. While we want to try +and avoid breaking changes, suggestions, new features, and incremental updates +are welcome! + ## 2.0.0-beta * Added `lazySpec` and `lazyCode` to lazily create code on visit [#145](https://github.com/dart-lang/code_builder/issues/145). diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0bf17f0..0dfd0f7 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -23,7 +23,7 @@ All submissions, including submissions by project members, require review. ### File headers All files in the project must start with the following header. - // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file + // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. diff --git a/pubspec.yaml b/pubspec.yaml index 74486e6..5dd0f77 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: code_builder -version: 2.0.0-beta +version: 2.0.0 description: A fluent API for generating Dart code author: Dart Team homepage: https://github.com/dart-lang/code_builder @@ -17,6 +17,5 @@ dependencies: dev_dependencies: build_runner: '>=0.4.0 <0.6.0' built_value_generator: '>=2.0.0 <5.0.0' - io: '>=0.1.0 <0.3.0' source_gen: '^0.7.0' test: ^0.12.0