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

Side by Side Diff: tools/json_schema_compiler/js_util.py

Issue 2650733002: Revert of Update json_schema_compiler to handle the Automation extension API (Closed)
Patch Set: Created 3 years, 11 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 unified diff | Download patch
OLDNEW
1 # Copyright 2015 The Chromium Authors. All rights reserved. 1 # Copyright 2015 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 from code import Code 5 from code import Code
6 from model import PropertyType 6 from model import PropertyType
7 7
8 from datetime import datetime 8 from datetime import datetime
9 9
10 LICENSE = """// Copyright %s The Chromium Authors. All rights reserved. 10 LICENSE = """// Copyright %s The Chromium Authors. All rights reserved.
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 self._TypeToJsType(namespace_name, function.returns), 94 self._TypeToJsType(namespace_name, function.returns),
95 '', False, function.returns.description) 95 '', False, function.returns.description)
96 96
97 if function.deprecated: 97 if function.deprecated:
98 c.Append('@deprecated %s' % function.deprecated) 98 c.Append('@deprecated %s' % function.deprecated)
99 99
100 c.Append(self.GetSeeLink(namespace_name, 'method', function.name)) 100 c.Append(self.GetSeeLink(namespace_name, 'method', function.name))
101 101
102 c.Eblock(' */') 102 c.Eblock(' */')
103 103
104 def AppendTypeJsDoc(self, c, namespace_name, js_type, optional):
105 """Appends the documentation for a type as a Code.
106 """
107 c.Append('@type {')
108 if optional:
109 c.Append('(', new_line=False)
110 c.Concat(self._TypeToJsType(namespace_name, js_type), new_line=False)
111 c.Append('|undefined)', new_line=False)
112 else:
113 c.Concat(self._TypeToJsType(namespace_name, js_type), new_line=False)
114 c.Append('}', new_line=False)
115
116 def _FunctionToJsFunction(self, namespace_name, function): 104 def _FunctionToJsFunction(self, namespace_name, function):
117 """Converts a model.Function to a JS type (i.e., function([params])...)""" 105 """Converts a model.Function to a JS type (i.e., function([params])...)"""
118 c = Code() 106 c = Code()
119 c.Append('function(') 107 c.Append('function(')
120 for i, param in enumerate(function.params): 108 for i, param in enumerate(function.params):
121 c.Concat(self._TypeToJsType(namespace_name, param.type_), new_line=False) 109 c.Concat(self._TypeToJsType(namespace_name, param.type_), new_line=False)
122 if i is not len(function.params) - 1: 110 if i is not len(function.params) - 1:
123 c.Append(', ', new_line=False, strip_right=False) 111 c.Append(', ', new_line=False, strip_right=False)
124 c.Append('):', new_line=False) 112 c.Append('):', new_line=False)
125 113
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 """Returns a @see link for a given API 'object' (type, method, or event). 160 """Returns a @see link for a given API 'object' (type, method, or event).
173 """ 161 """
174 162
175 # NOTE(devlin): This is kind of a hack. Some APIs will be hosted on 163 # NOTE(devlin): This is kind of a hack. Some APIs will be hosted on
176 # developer.chrome.com/apps/ instead of /extensions/, and some APIs have 164 # developer.chrome.com/apps/ instead of /extensions/, and some APIs have
177 # '.'s in them (like app.window), which should resolve to 'app_window'. 165 # '.'s in them (like app.window), which should resolve to 'app_window'.
178 # Luckily, the doc server has excellent url resolution, and knows exactly 166 # Luckily, the doc server has excellent url resolution, and knows exactly
179 # what we mean. This saves us from needing any complicated logic here. 167 # what we mean. This saves us from needing any complicated logic here.
180 return ('@see https://developer.chrome.com/extensions/%s#%s-%s' % 168 return ('@see https://developer.chrome.com/extensions/%s#%s-%s' %
181 (namespace_name, object_type, object_name)) 169 (namespace_name, object_type, object_name))
OLDNEW
« no previous file with comments | « tools/json_schema_compiler/js_externs_generator_test.py ('k') | tools/json_schema_compiler/model.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698