Chromium Code Reviews| 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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 Loading... | |
| 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)) |
| OLD | NEW |