[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 <sigmund@google.com> Commit-Queue: Srujan Gaddam <srujzs@google.com>
This commit is contained in:
committed by
Commit Queue
parent
143bbe0a05
commit
e872b7addd
@@ -1,3 +1,11 @@
|
||||
// Copyright (c) 2012, 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.
|
||||
|
||||
// DO NOT EDIT - unless you are editing documentation as per:
|
||||
// https://code.google.com/p/dart/wiki/ContributingHTMLDocumentation
|
||||
// Auto-generated dart:html library.
|
||||
|
||||
/// HTML elements and other resources for web-based applications that need to
|
||||
/// interact with the browser and the DOM (Document Object Model).
|
||||
///
|
||||
@@ -36,13 +44,6 @@ import 'dart:web_gl' as gl;
|
||||
import 'dart:web_gl' show RenderingContext, RenderingContext2;
|
||||
import 'dart:_foreign_helper' show JS, JS_INTERCEPTOR_CONSTANT;
|
||||
import 'dart:js_util' as js_util;
|
||||
// Copyright (c) 2012, 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.
|
||||
|
||||
// DO NOT EDIT - unless you are editing documentation as per:
|
||||
// https://code.google.com/p/dart/wiki/ContributingHTMLDocumentation
|
||||
// Auto-generated dart:html library.
|
||||
|
||||
// Not actually used, but imported since dart:html can generate these objects.
|
||||
import 'dart:_js_helper'
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
// Copyright (c) 2012, 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.
|
||||
|
||||
// DO NOT EDIT - unless you are editing documentation as per:
|
||||
// https://code.google.com/p/dart/wiki/ContributingHTMLDocumentation
|
||||
// Auto-generated dart:indexed_db library.
|
||||
|
||||
/// A client-side key-value store with support for indexes.
|
||||
///
|
||||
/// > [!Note]
|
||||
@@ -78,13 +86,6 @@ import 'dart:_js_helper' show Creates, Returns, JSName, Native;
|
||||
import 'dart:_foreign_helper' show JS;
|
||||
import 'dart:_interceptors' show JavaScriptObject, JSExtendableArray;
|
||||
import 'dart:_js_helper' show convertDartClosureToJS;
|
||||
// Copyright (c) 2012, 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.
|
||||
|
||||
// DO NOT EDIT - unless you are editing documentation as per:
|
||||
// https://code.google.com/p/dart/wiki/ContributingHTMLDocumentation
|
||||
// Auto-generated dart:indexed_db library.
|
||||
|
||||
class _KeyRangeFactoryProvider {
|
||||
static KeyRange createKeyRange_only(/*Key*/ value) =>
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
// DO NOT EDIT - unless you are editing documentation as per:
|
||||
// https://code.google.com/p/dart/wiki/ContributingHTMLDocumentation
|
||||
// Auto-generated dart:svg library.
|
||||
|
||||
/// Scalable Vector Graphics:
|
||||
/// Two-dimensional vector graphics with support for events and animation.
|
||||
///
|
||||
@@ -21,9 +25,6 @@ import 'dart:html_common';
|
||||
import 'dart:_js_helper' show Creates, Returns, JSName, Native;
|
||||
import 'dart:_foreign_helper' show JS;
|
||||
import 'dart:_interceptors' show JavaScriptObject;
|
||||
// DO NOT EDIT - unless you are editing documentation as per:
|
||||
// https://code.google.com/p/dart/wiki/ContributingHTMLDocumentation
|
||||
// Auto-generated dart:svg library.
|
||||
|
||||
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
// DO NOT EDIT - unless you are editing documentation as per:
|
||||
// https://code.google.com/p/dart/wiki/ContributingHTMLDocumentation
|
||||
// Auto-generated dart:audio library.
|
||||
|
||||
/// High-fidelity audio programming in the browser.
|
||||
///
|
||||
/// > [!Note]
|
||||
@@ -17,9 +21,6 @@ import 'dart:_native_typed_data';
|
||||
import 'dart:typed_data';
|
||||
import 'dart:_foreign_helper' show JS;
|
||||
import 'dart:_interceptors' show JavaScriptObject;
|
||||
// DO NOT EDIT - unless you are editing documentation as per:
|
||||
// https://code.google.com/p/dart/wiki/ContributingHTMLDocumentation
|
||||
// Auto-generated dart:audio library.
|
||||
|
||||
import 'dart:_js_helper'
|
||||
show
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
// DO NOT EDIT - unless you are editing documentation as per:
|
||||
// https://code.google.com/p/dart/wiki/ContributingHTMLDocumentation
|
||||
// Auto-generated dart:web_gl library.
|
||||
|
||||
/// 3D programming in the browser.
|
||||
///
|
||||
/// > [!Note]
|
||||
@@ -19,9 +23,6 @@ import 'dart:_js_helper'
|
||||
show Creates, JSName, Native, Returns, convertDartClosureToJS;
|
||||
import 'dart:_foreign_helper' show JS;
|
||||
import 'dart:_interceptors' show JavaScriptObject, JSExtendableArray;
|
||||
// DO NOT EDIT - unless you are editing documentation as per:
|
||||
// https://code.google.com/p/dart/wiki/ContributingHTMLDocumentation
|
||||
// Auto-generated dart:web_gl library.
|
||||
|
||||
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
// DO NOT EDIT - unless you are editing documentation as per:
|
||||
// https://code.google.com/p/dart/wiki/ContributingHTMLDocumentation
|
||||
// Auto-generated dart:web_sql library.
|
||||
|
||||
/// An API for storing data in the browser that can be queried with SQL.
|
||||
///
|
||||
/// **Caution:** this specification is no longer actively maintained by the Web
|
||||
@@ -9,6 +13,7 @@
|
||||
///
|
||||
/// {@category Web (Legacy)}
|
||||
/// {@nodoc}
|
||||
@deprecated
|
||||
library dart.dom.web_sql;
|
||||
|
||||
import 'dart:async';
|
||||
@@ -18,11 +23,7 @@ import 'dart:html';
|
||||
import 'dart:html_common';
|
||||
import 'dart:_foreign_helper' show JS;
|
||||
import 'dart:_interceptors' show JavaScriptObject;
|
||||
// DO NOT EDIT - unless you are editing documentation as per:
|
||||
// https://code.google.com/p/dart/wiki/ContributingHTMLDocumentation
|
||||
// Auto-generated dart:web_sql library.
|
||||
|
||||
@deprecated
|
||||
import 'dart:_js_helper'
|
||||
show
|
||||
applyExtension,
|
||||
|
||||
+16
-6
@@ -12,18 +12,22 @@ from os.path import basename, dirname, exists, isabs, join
|
||||
from glob import glob
|
||||
|
||||
re_directive = re.compile(r'^(library|import|part|native|resource)\s+(.*);$')
|
||||
re_comment = re.compile(r'^(///|/\*| \*).*$')
|
||||
re_comment = re.compile(r'^(///?|/\*| \*).*$')
|
||||
re_annotation = re.compile(r'^@.*$')
|
||||
re_newline = re.compile(r'\n')
|
||||
|
||||
|
||||
class Library(object):
|
||||
|
||||
def __init__(self, name, imports, sources, natives, code, comment):
|
||||
def __init__(self, name, imports, sources, natives, code, comment,
|
||||
annotations):
|
||||
self.name = name
|
||||
self.imports = imports
|
||||
self.sources = sources
|
||||
self.natives = natives
|
||||
self.code = code
|
||||
self.comment = comment
|
||||
self.annotations = annotations
|
||||
|
||||
|
||||
def parseLibrary(library):
|
||||
@@ -37,6 +41,7 @@ def parseLibrary(library):
|
||||
natives = []
|
||||
inlinecode = []
|
||||
librarycomment = []
|
||||
libraryannotations = []
|
||||
if exists(library):
|
||||
# TODO(sigmund): stop parsing when import/source
|
||||
for line in fileinput.input(library):
|
||||
@@ -56,14 +61,17 @@ def parseLibrary(library):
|
||||
raise Exception(
|
||||
'unknown directive %s in %s' % (directive, line))
|
||||
else:
|
||||
# Check for library comment.
|
||||
if not libraryname and re_comment.match(line):
|
||||
librarycomment.append(line)
|
||||
# Check for library comments and annotations.
|
||||
if not libraryname:
|
||||
if re_comment.match(line) or re_newline.match(line):
|
||||
librarycomment.append(line)
|
||||
elif re_annotation.match(line):
|
||||
libraryannotations.append(line)
|
||||
else:
|
||||
inlinecode.append(line)
|
||||
fileinput.close()
|
||||
return Library(libraryname, imports, sources, natives, inlinecode,
|
||||
librarycomment)
|
||||
librarycomment, libraryannotations)
|
||||
|
||||
|
||||
def normjoin(*args):
|
||||
@@ -126,6 +134,8 @@ except for dart files with absolute paths, which will be copied to
|
||||
if library.name:
|
||||
if library.comment:
|
||||
f.write('%s' % (''.join(library.comment)))
|
||||
if library.annotations:
|
||||
f.write('%s' % (''.join(library.annotations)))
|
||||
f.write("library %s;\n\n" % library.name)
|
||||
else:
|
||||
f.write("library %s;\n\n" % basename(lib))
|
||||
|
||||
@@ -206,6 +206,7 @@ def GenerateFromDatabase(common_database,
|
||||
def GenerateSingleFile(library_path, output_dir, generated_output_dir=None, prefix=None):
|
||||
library_dir = os.path.dirname(library_path)
|
||||
library_filename = os.path.basename(library_path)
|
||||
# Expand part files and concatenate them.
|
||||
copy_dart_script = os.path.relpath('../../copy_dart.py', library_dir)
|
||||
output_dir = os.path.relpath(output_dir, library_dir)
|
||||
if not os.path.exists(library_dir):
|
||||
|
||||
Reference in New Issue
Block a user