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

Side by Side 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 unified diff | Download patch
OLDNEW
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 class Code(object): 5 class Code(object):
6 """A convenience object for constructing code. 6 """A convenience object for constructing code.
7 7
8 Logically each object should be a block of code. All methods except |Render| 8 Logically each object should be a block of code. All methods except |Render|
9 and |IsEmpty| return self. 9 and |IsEmpty| return self.
10 """ 10 """
(...skipping 11 matching lines...) Expand all
22 """Appends a line of code at the current indent level or just a newline if 22 """Appends a line of code at the current indent level or just a newline if
23 line is not specified. 23 line is not specified.
24 24
25 substitute: indicated whether this line should be affected by 25 substitute: indicated whether this line should be affected by
26 code.Substitute(). 26 code.Substitute().
27 new_line: whether this should be added as a new line, or should be appended 27 new_line: whether this should be added as a new line, or should be appended
28 to the last line of the code. 28 to the last line of the code.
29 strip_right: whether or not trailing whitespace should be stripped. 29 strip_right: whether or not trailing whitespace should be stripped.
30 """ 30 """
31 31
32 prefix = indent_level * ' ' if indent_level else ''.join( 32 if line:
33 prefix = indent_level * ' ' if indent_level else ''.join(
33 self._line_prefixes) 34 self._line_prefixes)
35 else:
36 prefix = ''
34 37
35 if strip_right: 38 if strip_right:
36 line = line.rstrip() 39 line = line.rstrip()
37 40
38 if not new_line and self._code: 41 if not new_line and self._code:
39 self._code[-1].value += line 42 self._code[-1].value += line
40 else: 43 else:
41 self._code.append(Line(prefix + line, substitute=substitute)) 44 self._code.append(Line(prefix + line, substitute=substitute))
42 return self 45 return self
43 46
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 """ 178 """
176 return '\n'.join([l.value for l in self._code]) 179 return '\n'.join([l.value for l in self._code])
177 180
178 181
179 class Line(object): 182 class Line(object):
180 """A line of code. 183 """A line of code.
181 """ 184 """
182 def __init__(self, value, substitute=True): 185 def __init__(self, value, substitute=True):
183 self.value = value 186 self.value = value
184 self.substitute = substitute 187 self.substitute = substitute
OLDNEW
« no previous file with comments | « no previous file | tools/json_schema_compiler/compiler.py » ('j') | tools/json_schema_compiler/js_interface_generator.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698