| OLD | NEW |
| 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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 c = Code() | 141 c = Code() |
| 142 c.Append('(') | 142 c.Append('(') |
| 143 for i, choice in enumerate(js_type.choices): | 143 for i, choice in enumerate(js_type.choices): |
| 144 c.Concat(self._TypeToJsType(namespace_name, choice), new_line=False) | 144 c.Concat(self._TypeToJsType(namespace_name, choice), new_line=False) |
| 145 if i is not len(js_type.choices) - 1: | 145 if i is not len(js_type.choices) - 1: |
| 146 c.Append('|', new_line=False) | 146 c.Append('|', new_line=False) |
| 147 c.Append(')', new_line=False) | 147 c.Append(')', new_line=False) |
| 148 return c | 148 return c |
| 149 if js_type.property_type is PropertyType.FUNCTION: | 149 if js_type.property_type is PropertyType.FUNCTION: |
| 150 return self._FunctionToJsFunction(namespace_name, js_type.function) | 150 return self._FunctionToJsFunction(namespace_name, js_type.function) |
| 151 if js_type.property_type is PropertyType.BINARY: |
| 152 return Code().Append('ArrayBuffer') |
| 151 if js_type.property_type is PropertyType.ANY: | 153 if js_type.property_type is PropertyType.ANY: |
| 152 return Code().Append('*') | 154 return Code().Append('*') |
| 153 if js_type.property_type.is_fundamental: | 155 if js_type.property_type.is_fundamental: |
| 154 return Code().Append(js_type.property_type.name) | 156 return Code().Append(js_type.property_type.name) |
| 155 return Code().Append('?') # TODO(tbreisacher): Make this more specific. | 157 return Code().Append('?') # TODO(tbreisacher): Make this more specific. |
| 156 | 158 |
| 157 def GetSeeLink(self, namespace_name, object_type, object_name): | 159 def GetSeeLink(self, namespace_name, object_type, object_name): |
| 158 """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). |
| 159 """ | 161 """ |
| 160 | 162 |
| 161 # 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 |
| 162 # developer.chrome.com/apps/ instead of /extensions/, and some APIs have | 164 # developer.chrome.com/apps/ instead of /extensions/, and some APIs have |
| 163 # '.'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'. |
| 164 # Luckily, the doc server has excellent url resolution, and knows exactly | 166 # Luckily, the doc server has excellent url resolution, and knows exactly |
| 165 # 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. |
| 166 return ('@see https://developer.chrome.com/extensions/%s#%s-%s' % | 168 return ('@see https://developer.chrome.com/extensions/%s#%s-%s' % |
| 167 (namespace_name, object_type, object_name)) | 169 (namespace_name, object_type, object_name)) |
| OLD | NEW |