Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(140)

Unified Diff: tools/copy_dart.py

Issue 12315102: Fix copy_dart to correctly put library comments BEFORE the library directive. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: tools/copy_dart.py
diff --git a/tools/copy_dart.py b/tools/copy_dart.py
index b60ad8911e39ab86b9ca021602cf71cb6e3a1c50..9918e2ec0f0b1047d1fb1bfdd17d2e26c6900dea 100755
--- a/tools/copy_dart.py
+++ b/tools/copy_dart.py
@@ -14,14 +14,17 @@ from glob import glob
re_directive = re.compile(
r'^(library|import|part|native|resource)\s+(.*);$')
+re_comment = re.compile(
+ r'^(///|/\*| \*).*$')
class Library(object):
- def __init__(self, name, imports, sources, natives, code):
+ def __init__(self, name, imports, sources, natives, code, comment):
self.name = name
self.imports = imports
self.sources = sources
self.natives = natives
self.code = code
+ self.comment = comment
def parseLibrary(library):
""" Parses a .dart source file that is the root of a library, and returns
@@ -33,6 +36,7 @@ def parseLibrary(library):
sources = []
natives = []
inlinecode = []
+ librarycomment = []
if exists(library):
# TODO(sigmund): stop parsing when import/source
for line in fileinput.input(library):
@@ -51,9 +55,14 @@ def parseLibrary(library):
else:
raise Exception('unknown directive %s in %s' % (directive, line))
else:
- inlinecode.append(line)
+ # Check for library comment.
+ if not libraryname and re_comment.match(line):
+ librarycomment.append(line)
+ else:
+ inlinecode.append(line)
fileinput.close()
- return Library(libraryname, imports, sources, natives, inlinecode)
+ return Library(libraryname, imports, sources, natives, inlinecode,
+ librarycomment)
def normjoin(*args):
return os.path.normpath(os.path.join(*args))
@@ -114,6 +123,8 @@ def main(outdir = None, *inputs):
# Create file containing all imports, and inlining all sources
with open(outpath, 'w') as f:
if library.name:
+ if library.comment:
+ f.write('%s' % (''.join(library.comment)))
f.write("library %s;\n\n" % library.name)
else:
f.write("library %s;\n\n" % basename(lib))
« no previous file with comments | « sdk/lib/html/dartium/html_dartium.dart ('k') | tools/dom/templates/html/dart2js/chrome_dart2js.darttemplate » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698