Skip to content

Commit e872b7a

Browse files
srujzsCommit Queue
authored andcommitted
[web libraries] Capture annotations and header comments when expanding parts
copy_dart.py parses the generated web libraries to split them into components so that it can expand part declarations. This script should recognize any annotations and header comments (like the license) so that it can accurately copy them over. Ideally, we shouldn't be parsing anything besides the part declarations and expanding them as we just attempt to copy anything else, but that can be done in a future change. Note that this change adds @deprecated back to the library declaration in web_sql_dart2js.dart. It makes no difference, however, as it's a compile time error to import dart:web_sql anyways. CoreLibraryReviewExempt: Doc-only change. Change-Id: Iad974434b858ea36358f908e8a25987105c586c7 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/401801 Reviewed-by: Sigmund Cherem <[email protected]> Commit-Queue: Srujan Gaddam <[email protected]>
1 parent 143bbe0 commit e872b7a

File tree

8 files changed

+50
-33
lines changed

8 files changed

+50
-33
lines changed

sdk/lib/html/dart2js/html_dart2js.dart

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
// Copyright (c) 2012, 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+
// DO NOT EDIT - unless you are editing documentation as per:
6+
// https://code.google.com/p/dart/wiki/ContributingHTMLDocumentation
7+
// Auto-generated dart:html library.
8+
19
/// HTML elements and other resources for web-based applications that need to
210
/// interact with the browser and the DOM (Document Object Model).
311
///
@@ -36,13 +44,6 @@ import 'dart:web_gl' as gl;
3644
import 'dart:web_gl' show RenderingContext, RenderingContext2;
3745
import 'dart:_foreign_helper' show JS, JS_INTERCEPTOR_CONSTANT;
3846
import 'dart:js_util' as js_util;
39-
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
40-
// for details. All rights reserved. Use of this source code is governed by a
41-
// BSD-style license that can be found in the LICENSE file.
42-
43-
// DO NOT EDIT - unless you are editing documentation as per:
44-
// https://code.google.com/p/dart/wiki/ContributingHTMLDocumentation
45-
// Auto-generated dart:html library.
4647

4748
// Not actually used, but imported since dart:html can generate these objects.
4849
import 'dart:_js_helper'

sdk/lib/indexed_db/dart2js/indexed_db_dart2js.dart

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
// Copyright (c) 2012, 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+
// DO NOT EDIT - unless you are editing documentation as per:
6+
// https://code.google.com/p/dart/wiki/ContributingHTMLDocumentation
7+
// Auto-generated dart:indexed_db library.
8+
19
/// A client-side key-value store with support for indexes.
210
///
311
/// > [!Note]
@@ -78,13 +86,6 @@ import 'dart:_js_helper' show Creates, Returns, JSName, Native;
7886
import 'dart:_foreign_helper' show JS;
7987
import 'dart:_interceptors' show JavaScriptObject, JSExtendableArray;
8088
import 'dart:_js_helper' show convertDartClosureToJS;
81-
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
82-
// for details. All rights reserved. Use of this source code is governed by a
83-
// BSD-style license that can be found in the LICENSE file.
84-
85-
// DO NOT EDIT - unless you are editing documentation as per:
86-
// https://code.google.com/p/dart/wiki/ContributingHTMLDocumentation
87-
// Auto-generated dart:indexed_db library.
8889

8990
class _KeyRangeFactoryProvider {
9091
static KeyRange createKeyRange_only(/*Key*/ value) =>

sdk/lib/svg/dart2js/svg_dart2js.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// DO NOT EDIT - unless you are editing documentation as per:
2+
// https://code.google.com/p/dart/wiki/ContributingHTMLDocumentation
3+
// Auto-generated dart:svg library.
4+
15
/// Scalable Vector Graphics:
26
/// Two-dimensional vector graphics with support for events and animation.
37
///
@@ -21,9 +25,6 @@ import 'dart:html_common';
2125
import 'dart:_js_helper' show Creates, Returns, JSName, Native;
2226
import 'dart:_foreign_helper' show JS;
2327
import 'dart:_interceptors' show JavaScriptObject;
24-
// DO NOT EDIT - unless you are editing documentation as per:
25-
// https://code.google.com/p/dart/wiki/ContributingHTMLDocumentation
26-
// Auto-generated dart:svg library.
2728

2829
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2930
// for details. All rights reserved. Use of this source code is governed by a

sdk/lib/web_audio/dart2js/web_audio_dart2js.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// DO NOT EDIT - unless you are editing documentation as per:
2+
// https://code.google.com/p/dart/wiki/ContributingHTMLDocumentation
3+
// Auto-generated dart:audio library.
4+
15
/// High-fidelity audio programming in the browser.
26
///
37
/// > [!Note]
@@ -17,9 +21,6 @@ import 'dart:_native_typed_data';
1721
import 'dart:typed_data';
1822
import 'dart:_foreign_helper' show JS;
1923
import 'dart:_interceptors' show JavaScriptObject;
20-
// DO NOT EDIT - unless you are editing documentation as per:
21-
// https://code.google.com/p/dart/wiki/ContributingHTMLDocumentation
22-
// Auto-generated dart:audio library.
2324

2425
import 'dart:_js_helper'
2526
show

sdk/lib/web_gl/dart2js/web_gl_dart2js.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// DO NOT EDIT - unless you are editing documentation as per:
2+
// https://code.google.com/p/dart/wiki/ContributingHTMLDocumentation
3+
// Auto-generated dart:web_gl library.
4+
15
/// 3D programming in the browser.
26
///
37
/// > [!Note]
@@ -19,9 +23,6 @@ import 'dart:_js_helper'
1923
show Creates, JSName, Native, Returns, convertDartClosureToJS;
2024
import 'dart:_foreign_helper' show JS;
2125
import 'dart:_interceptors' show JavaScriptObject, JSExtendableArray;
22-
// DO NOT EDIT - unless you are editing documentation as per:
23-
// https://code.google.com/p/dart/wiki/ContributingHTMLDocumentation
24-
// Auto-generated dart:web_gl library.
2526

2627
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2728
// for details. All rights reserved. Use of this source code is governed by a

sdk/lib/web_sql/dart2js/web_sql_dart2js.dart

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// DO NOT EDIT - unless you are editing documentation as per:
2+
// https://code.google.com/p/dart/wiki/ContributingHTMLDocumentation
3+
// Auto-generated dart:web_sql library.
4+
15
/// An API for storing data in the browser that can be queried with SQL.
26
///
37
/// **Caution:** this specification is no longer actively maintained by the Web
@@ -9,6 +13,7 @@
913
///
1014
/// {@category Web (Legacy)}
1115
/// {@nodoc}
16+
@deprecated
1217
library dart.dom.web_sql;
1318

1419
import 'dart:async';
@@ -18,11 +23,7 @@ import 'dart:html';
1823
import 'dart:html_common';
1924
import 'dart:_foreign_helper' show JS;
2025
import 'dart:_interceptors' show JavaScriptObject;
21-
// DO NOT EDIT - unless you are editing documentation as per:
22-
// https://code.google.com/p/dart/wiki/ContributingHTMLDocumentation
23-
// Auto-generated dart:web_sql library.
2426

25-
@deprecated
2627
import 'dart:_js_helper'
2728
show
2829
applyExtension,

tools/copy_dart.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,22 @@
1212
from glob import glob
1313

1414
re_directive = re.compile(r'^(library|import|part|native|resource)\s+(.*);$')
15-
re_comment = re.compile(r'^(///|/\*| \*).*$')
15+
re_comment = re.compile(r'^(///?|/\*| \*).*$')
16+
re_annotation = re.compile(r'^@.*$')
17+
re_newline = re.compile(r'\n')
1618

1719

1820
class Library(object):
1921

20-
def __init__(self, name, imports, sources, natives, code, comment):
22+
def __init__(self, name, imports, sources, natives, code, comment,
23+
annotations):
2124
self.name = name
2225
self.imports = imports
2326
self.sources = sources
2427
self.natives = natives
2528
self.code = code
2629
self.comment = comment
30+
self.annotations = annotations
2731

2832

2933
def parseLibrary(library):
@@ -37,6 +41,7 @@ def parseLibrary(library):
3741
natives = []
3842
inlinecode = []
3943
librarycomment = []
44+
libraryannotations = []
4045
if exists(library):
4146
# TODO(sigmund): stop parsing when import/source
4247
for line in fileinput.input(library):
@@ -56,14 +61,17 @@ def parseLibrary(library):
5661
raise Exception(
5762
'unknown directive %s in %s' % (directive, line))
5863
else:
59-
# Check for library comment.
60-
if not libraryname and re_comment.match(line):
61-
librarycomment.append(line)
64+
# Check for library comments and annotations.
65+
if not libraryname:
66+
if re_comment.match(line) or re_newline.match(line):
67+
librarycomment.append(line)
68+
elif re_annotation.match(line):
69+
libraryannotations.append(line)
6270
else:
6371
inlinecode.append(line)
6472
fileinput.close()
6573
return Library(libraryname, imports, sources, natives, inlinecode,
66-
librarycomment)
74+
librarycomment, libraryannotations)
6775

6876

6977
def normjoin(*args):
@@ -126,6 +134,8 @@ def main(outdir=None, *inputs):
126134
if library.name:
127135
if library.comment:
128136
f.write('%s' % (''.join(library.comment)))
137+
if library.annotations:
138+
f.write('%s' % (''.join(library.annotations)))
129139
f.write("library %s;\n\n" % library.name)
130140
else:
131141
f.write("library %s;\n\n" % basename(lib))

tools/dom/scripts/dartdomgenerator.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ def generate_interface(interface, gl_constants=None):
206206
def GenerateSingleFile(library_path, output_dir, generated_output_dir=None, prefix=None):
207207
library_dir = os.path.dirname(library_path)
208208
library_filename = os.path.basename(library_path)
209+
# Expand part files and concatenate them.
209210
copy_dart_script = os.path.relpath('../../copy_dart.py', library_dir)
210211
output_dir = os.path.relpath(output_dir, library_dir)
211212
if not os.path.exists(library_dir):

0 commit comments

Comments
 (0)