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

Unified Diff: tools/json_schema_compiler/code.py

Issue 1488773003: Add js_interface_generator for generating extensions interfaces (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 5 years 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
« no previous file with comments | « no previous file | tools/json_schema_compiler/compiler.py » ('j') | tools/json_schema_compiler/compiler.py » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/json_schema_compiler/code.py
diff --git a/tools/json_schema_compiler/code.py b/tools/json_schema_compiler/code.py
index e454e5d444039808553ae73e2f74823f81133fb3..76e31bccfa5f3406c54f1a0f572a82875df6d1a8 100644
--- a/tools/json_schema_compiler/code.py
+++ b/tools/json_schema_compiler/code.py
@@ -29,8 +29,11 @@ class Code(object):
strip_right: whether or not trailing whitespace should be stripped.
"""
- prefix = indent_level * ' ' if indent_level else ''.join(
+ if line:
+ prefix = indent_level * ' ' if indent_level else ''.join(
self._line_prefixes)
michaelpg 2015/12/04 21:02:19 4-space indent
stevenjb 2015/12/07 18:31:24 Done.
+ else:
+ prefix = ''
if strip_right:
line = line.rstrip()
@@ -170,6 +173,14 @@ class Code(object):
self._code[i].substitute = False
return self
+ def TrimTrailingNewlines(self):
+ """Trims any trailing newlines
michaelpg 2015/12/04 21:02:19 nit: period
stevenjb 2015/12/07 18:31:24 Done.
+ """
+ while len(self._code) > 0:
michaelpg 2015/12/04 21:02:19 opt nit: "while self._code:" (cf lines 41, 50, 63,
stevenjb 2015/12/07 18:31:24 Done.
+ if self._code[-1].value != '':
+ return
+ self._code = self._code[:-1]
+
def Render(self):
"""Renders Code as a string.
"""
« no previous file with comments | « no previous file | tools/json_schema_compiler/compiler.py » ('j') | tools/json_schema_compiler/compiler.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698