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

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

Issue 2601333002: Update json_schema_compiler to handle the Automation extension API (Closed)
Patch Set: Fix select_to_speak 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):
105 """Appends the documentation for a type as a Code.
106 """
107 c.Append('@type {')
108 c.Concat(self._TypeToJsType(namespace_name, js_type), new_line = False)
Dan Beam 2017/01/10 22:54:43 new_line=False
dmazzoni 2017/01/11 22:20:42 Done.
109 c.Append('}', new_line = False)
110
104 def _FunctionToJsFunction(self, namespace_name, function): 111 def _FunctionToJsFunction(self, namespace_name, function):
105 """Converts a model.Function to a JS type (i.e., function([params])...)""" 112 """Converts a model.Function to a JS type (i.e., function([params])...)"""
106 c = Code() 113 c = Code()
107 c.Append('function(') 114 c.Append('function(')
108 for i, param in enumerate(function.params): 115 for i, param in enumerate(function.params):
109 c.Concat(self._TypeToJsType(namespace_name, param.type_), new_line=False) 116 c.Concat(self._TypeToJsType(namespace_name, param.type_), new_line=False)
110 if i is not len(function.params) - 1: 117 if i is not len(function.params) - 1:
111 c.Append(', ', new_line=False, strip_right=False) 118 c.Append(', ', new_line=False, strip_right=False)
112 c.Append('):', new_line=False) 119 c.Append('):', new_line=False)
113 120
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 """Returns a @see link for a given API 'object' (type, method, or event). 167 """Returns a @see link for a given API 'object' (type, method, or event).
161 """ 168 """
162 169
163 # NOTE(devlin): This is kind of a hack. Some APIs will be hosted on 170 # NOTE(devlin): This is kind of a hack. Some APIs will be hosted on
164 # developer.chrome.com/apps/ instead of /extensions/, and some APIs have 171 # developer.chrome.com/apps/ instead of /extensions/, and some APIs have
165 # '.'s in them (like app.window), which should resolve to 'app_window'. 172 # '.'s in them (like app.window), which should resolve to 'app_window'.
166 # Luckily, the doc server has excellent url resolution, and knows exactly 173 # Luckily, the doc server has excellent url resolution, and knows exactly
167 # what we mean. This saves us from needing any complicated logic here. 174 # what we mean. This saves us from needing any complicated logic here.
168 return ('@see https://developer.chrome.com/extensions/%s#%s-%s' % 175 return ('@see https://developer.chrome.com/extensions/%s#%s-%s' %
169 (namespace_name, object_type, object_name)) 176 (namespace_name, object_type, object_name))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698