Skip to content
This repository has been archived by the owner on Nov 1, 2024. It is now read-only.

Commit

Permalink
support empty line comments
Browse files Browse the repository at this point in the history
  • Loading branch information
devoncarew committed Nov 29, 2023
1 parent 10ebf2a commit 9febb96
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 4.8.1

* Emit empty line comments as empty lines.

## 4.8.0

* Add `Expression.operatorSubtract`
Expand Down
4 changes: 3 additions & 1 deletion lib/src/emitter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,9 @@ class DartEmitter extends Object
output ??= StringBuffer();

if (spec.comments.isNotEmpty) {
spec.comments.map((line) => '// $line').forEach(output.writeln);
spec.comments
.map((line) => line.isEmpty ? '' : '// $line')
.forEach(output.writeln);
output.writeln();
}

Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: code_builder
version: 4.8.0
version: 4.8.1
description: >-
A fluent, builder-based library for generating valid Dart code
repository: https://github.com/dart-lang/code_builder
Expand Down
2 changes: 1 addition & 1 deletion test/specs/library_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ void main() {
),
equalsDart(r'''
// Generated by foo!
//
// Avoid editing by hand.
class Foo { }
Expand Down

0 comments on commit 9febb96

Please sign in to comment.