OLD | NEW |
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 import copy | 5 import copy |
6 import os | 6 import os |
7 | 7 |
8 from docs_server_utils import GetLinkToRefType | 8 from docs_server_utils import GetLinkToRefType |
9 import third_party.json_schema_compiler.model as model | 9 import third_party.json_schema_compiler.model as model |
10 | 10 |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 function_dict['parameters'].append(function_dict['callback']) | 105 function_dict['parameters'].append(function_dict['callback']) |
106 if len(function_dict['parameters']) > 0: | 106 if len(function_dict['parameters']) > 0: |
107 function_dict['parameters'][-1]['last'] = True | 107 function_dict['parameters'][-1]['last'] = True |
108 return function_dict | 108 return function_dict |
109 | 109 |
110 def _GenerateEvent(self, event): | 110 def _GenerateEvent(self, event): |
111 event_dict = { | 111 event_dict = { |
112 'name': self._StripPrefix(event.name), | 112 'name': self._StripPrefix(event.name), |
113 'description': self._FormatDescription(event.description), | 113 'description': self._FormatDescription(event.description), |
114 'parameters': map(self._GenerateProperty, event.params), | 114 'parameters': map(self._GenerateProperty, event.params), |
| 115 'callback': self._GenerateCallback(event.callback), |
115 'conditions': [GetLinkToRefType(self._namespace.name, c) | 116 'conditions': [GetLinkToRefType(self._namespace.name, c) |
116 for c in event.conditions], | 117 for c in event.conditions], |
117 'actions': [GetLinkToRefType(self._namespace.name, a) | 118 'actions': [GetLinkToRefType(self._namespace.name, a) |
118 for a in event.actions], | 119 for a in event.actions], |
119 'filters': map(self._GenerateProperty, event.filters), | 120 'filters': map(self._GenerateProperty, event.filters), |
120 'supportsRules': event.supports_rules | 121 'supportsRules': event.supports_rules |
121 } | 122 } |
| 123 if event_dict['callback']: |
| 124 event_dict['parameters'].append(event_dict['callback']) |
122 if len(event_dict['parameters']) > 0: | 125 if len(event_dict['parameters']) > 0: |
123 event_dict['parameters'][-1]['last'] = True | 126 event_dict['parameters'][-1]['last'] = True |
124 return event_dict | 127 return event_dict |
125 | 128 |
126 def _GenerateCallback(self, callback): | 129 def _GenerateCallback(self, callback): |
127 if not callback: | 130 if not callback: |
128 return None | 131 return None |
129 callback_dict = { | 132 callback_dict = { |
130 'name': callback.name, | 133 'name': callback.name, |
131 'description': self._FormatDescription(callback.description), | 134 'description': self._FormatDescription(callback.description), |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 elif property_.type_ == model.PropertyType.ENUM: | 180 elif property_.type_ == model.PropertyType.ENUM: |
178 dst_dict['enum_values'] = [] | 181 dst_dict['enum_values'] = [] |
179 for enum_value in property_.enum_values: | 182 for enum_value in property_.enum_values: |
180 dst_dict['enum_values'].append({'name': enum_value}) | 183 dst_dict['enum_values'].append({'name': enum_value}) |
181 if len(dst_dict['enum_values']) > 0: | 184 if len(dst_dict['enum_values']) > 0: |
182 dst_dict['enum_values'][-1]['last'] = True | 185 dst_dict['enum_values'][-1]['last'] = True |
183 elif property_.instance_of is not None: | 186 elif property_.instance_of is not None: |
184 dst_dict['simple_type'] = property_.instance_of.lower() | 187 dst_dict['simple_type'] = property_.instance_of.lower() |
185 else: | 188 else: |
186 dst_dict['simple_type'] = property_.type_.name.lower() | 189 dst_dict['simple_type'] = property_.type_.name.lower() |
OLD | NEW |