Skip to content

Commit

Permalink
Remove copyright headers from injected sample source
Browse files Browse the repository at this point in the history
  • Loading branch information
parlough committed Nov 17, 2024
1 parent fb525f9 commit 999ae83
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 35 deletions.
30 changes: 3 additions & 27 deletions pkgs/dartpad_ui/lib/samples.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions pkgs/samples/lib/default_dart.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright (c) 2024, 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.

void main() {
for (var i = 0; i < 10; i++) {
print('hello ${i + 1}');
Expand Down
4 changes: 4 additions & 0 deletions pkgs/samples/lib/default_flutter.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright (c) 2024, 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:flutter/material.dart';

void main() {
Expand Down
22 changes: 14 additions & 8 deletions pkgs/samples/tool/samples.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright 2023 the Dart project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file.
// Copyright (c) 2023, 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 'dart:convert';
import 'dart:io';
Expand Down Expand Up @@ -146,9 +146,9 @@ ${samples.map((s) => s.toTableRow()).join('\n')}

String _generateSourceContent() {
final buf = StringBuffer('''
// Copyright 2023 the Dart project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file.
// Copyright (c) 2023, 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.
// This file has been automatically generated - please do not edit it manually.
Expand Down Expand Up @@ -243,7 +243,10 @@ class Sample implements Comparable<Sample> {
return '_$gen';
}

String get source => File(path).readAsStringSync();
String get _rawSource => File(path).readAsStringSync();

String get source =>
_rawSource.replaceFirst(_copyrightCommentPattern, '').trim();

String get sourceDef {
return '''
Expand All @@ -253,7 +256,7 @@ const $sourceId = Sample(
name: '$name',
id: '$id',
source: r\'\'\'
${source.trimRight()}
$source
\'\'\',
);
''';
Expand All @@ -276,4 +279,7 @@ ${source.trimRight()}

static String _idFromName(String name) =>
name.trim().toLowerCase().replaceAll(' ', '-');

static final RegExp _copyrightCommentPattern =
RegExp(r'^\/\/ Copyright.*LICENSE file.', multiLine: true, dotAll: true);
}

0 comments on commit 999ae83

Please sign in to comment.