| 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 json | 6 import json |
| 7 import logging | 7 import logging |
| 8 import os | 8 import os |
| 9 from collections import defaultdict, Mapping | 9 from collections import defaultdict, Mapping |
| 10 | 10 |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 | 172 |
| 173 def _GenerateFunction(self, function): | 173 def _GenerateFunction(self, function): |
| 174 function_dict = { | 174 function_dict = { |
| 175 'name': function.simple_name, | 175 'name': function.simple_name, |
| 176 'description': self._FormatDescription(function.description), | 176 'description': self._FormatDescription(function.description), |
| 177 'callback': self._GenerateCallback(function.callback), | 177 'callback': self._GenerateCallback(function.callback), |
| 178 'parameters': [], | 178 'parameters': [], |
| 179 'returns': None, | 179 'returns': None, |
| 180 'id': _CreateId(function, 'method') | 180 'id': _CreateId(function, 'method') |
| 181 } | 181 } |
| 182 if (function.deprecated is not None): | 182 if function.deprecated is not None: |
| 183 function_dict['deprecated'] = self._FormatDescription( | 183 function_dict['deprecated'] = self._FormatDescription( |
| 184 function.deprecated) | 184 function.deprecated) |
| 185 if (function.parent is not None and | 185 if (function.parent is not None and |
| 186 not isinstance(function.parent, model.Namespace)): | 186 not isinstance(function.parent, model.Namespace)): |
| 187 function_dict['parentName'] = function.parent.simple_name | 187 function_dict['parentName'] = function.parent.simple_name |
| 188 if function.returns: | 188 if function.returns: |
| 189 function_dict['returns'] = self._GenerateType(function.returns) | 189 function_dict['returns'] = self._GenerateType(function.returns) |
| 190 for param in function.params: | 190 for param in function.params: |
| 191 function_dict['parameters'].append(self._GenerateProperty(param)) | 191 function_dict['parameters'].append(self._GenerateProperty(param)) |
| 192 if function.callback is not None: | 192 if function.callback is not None: |
| (...skipping 19 matching lines...) Expand all Loading... |
| 212 'filters': [self._GenerateProperty(f) for f in event.filters], | 212 'filters': [self._GenerateProperty(f) for f in event.filters], |
| 213 'conditions': [self._GetLink(condition) | 213 'conditions': [self._GetLink(condition) |
| 214 for condition in event.conditions], | 214 for condition in event.conditions], |
| 215 'actions': [self._GetLink(action) for action in event.actions], | 215 'actions': [self._GetLink(action) for action in event.actions], |
| 216 'supportsRules': event.supports_rules, | 216 'supportsRules': event.supports_rules, |
| 217 'supportsListeners': event.supports_listeners, | 217 'supportsListeners': event.supports_listeners, |
| 218 'properties': [], | 218 'properties': [], |
| 219 'id': _CreateId(event, 'event'), | 219 'id': _CreateId(event, 'event'), |
| 220 'byName': {}, | 220 'byName': {}, |
| 221 } | 221 } |
| 222 if event.deprecated is not None: |
| 223 event_dict['deprecated'] = self._FormatDescription( |
| 224 event.deprecated) |
| 222 if (event.parent is not None and | 225 if (event.parent is not None and |
| 223 not isinstance(event.parent, model.Namespace)): | 226 not isinstance(event.parent, model.Namespace)): |
| 224 event_dict['parentName'] = event.parent.simple_name | 227 event_dict['parentName'] = event.parent.simple_name |
| 225 # Add the Event members to each event in this object. | 228 # Add the Event members to each event in this object. |
| 226 # If refs are disabled then don't worry about this, since it's only needed | 229 # If refs are disabled then don't worry about this, since it's only needed |
| 227 # for rendering, and disable_refs=True implies we're not rendering. | 230 # for rendering, and disable_refs=True implies we're not rendering. |
| 228 if self._event_byname_function and not self._disable_refs: | 231 if self._event_byname_function and not self._disable_refs: |
| 229 event_dict['byName'].update(self._event_byname_function()) | 232 event_dict['byName'].update(self._event_byname_function()) |
| 230 # We need to create the method description for addListener based on the | 233 # We need to create the method description for addListener based on the |
| 231 # information stored in |event|. | 234 # information stored in |event|. |
| (...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 659 | 662 |
| 660 if disable_refs: | 663 if disable_refs: |
| 661 cache, ext = ( | 664 cache, ext = ( |
| 662 (self._idl_cache_no_refs, '.idl') if (unix_name in idl_names) else | 665 (self._idl_cache_no_refs, '.idl') if (unix_name in idl_names) else |
| 663 (self._json_cache_no_refs, '.json')) | 666 (self._json_cache_no_refs, '.json')) |
| 664 else: | 667 else: |
| 665 cache, ext = ((self._idl_cache, '.idl') if (unix_name in idl_names) else | 668 cache, ext = ((self._idl_cache, '.idl') if (unix_name in idl_names) else |
| 666 (self._json_cache, '.json')) | 669 (self._json_cache, '.json')) |
| 667 return self._GenerateHandlebarContext( | 670 return self._GenerateHandlebarContext( |
| 668 cache.GetFromFile('%s/%s%s' % (self._base_path, unix_name, ext)).Get()) | 671 cache.GetFromFile('%s/%s%s' % (self._base_path, unix_name, ext)).Get()) |
| OLD | NEW |