| OLD | NEW |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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 copy import copy | 5 from copy import copy |
| 6 import logging | 6 import logging |
| 7 import posixpath | 7 import posixpath |
| 8 | 8 |
| 9 from api_models import GetNodeCategories | 9 from api_models import GetNodeCategories |
| 10 from api_schema_graph import APINodeCursor | 10 from api_schema_graph import APINodeCursor |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 '''Returns a dictionary representation of a type from JSON Schema Compiler. | 226 '''Returns a dictionary representation of a type from JSON Schema Compiler. |
| 227 ''' | 227 ''' |
| 228 with self._current_node.Descend(type_.simple_name): | 228 with self._current_node.Descend(type_.simple_name): |
| 229 type_dict = { | 229 type_dict = { |
| 230 'name': type_.simple_name, | 230 'name': type_.simple_name, |
| 231 'description': type_.description, | 231 'description': type_.description, |
| 232 'properties': self._GenerateProperties(type_.properties), | 232 'properties': self._GenerateProperties(type_.properties), |
| 233 'functions': self._GenerateFunctions(type_.functions), | 233 'functions': self._GenerateFunctions(type_.functions), |
| 234 'events': self._GenerateEvents(type_.events), | 234 'events': self._GenerateEvents(type_.events), |
| 235 'id': _CreateId(type_, 'type'), | 235 'id': _CreateId(type_, 'type'), |
| 236 'availability': self._GetAvailabilityTemplate() | 236 'availability': self._GetAvailabilityTemplate( |
| 237 is_enum=type_.property_type == model.PropertyType.ENUM) |
| 237 } | 238 } |
| 238 self._RenderTypeInformation(type_, type_dict) | 239 self._RenderTypeInformation(type_, type_dict) |
| 239 return type_dict | 240 return type_dict |
| 240 | 241 |
| 241 def _GenerateFunctions(self, functions): | 242 def _GenerateFunctions(self, functions): |
| 242 '''Returns a list of dictionaries representing this Model's functions. | 243 '''Returns a list of dictionaries representing this Model's functions. |
| 243 ''' | 244 ''' |
| 244 with self._current_node.Descend('functions'): | 245 with self._current_node.Descend('functions'): |
| 245 return [self._GenerateFunction(f) for f in functions.values()] | 246 return [self._GenerateFunction(f) for f in functions.values()] |
| 246 | 247 |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 437 '''Returns an object suitable for use in templates to display availability | 438 '''Returns an object suitable for use in templates to display availability |
| 438 information. | 439 information. |
| 439 ''' | 440 ''' |
| 440 return { | 441 return { |
| 441 'partial': self._template_cache.GetFromFile( | 442 'partial': self._template_cache.GetFromFile( |
| 442 '%sintro_tables/%s_message.html' % (PRIVATE_TEMPLATES, status)).Get(), | 443 '%sintro_tables/%s_message.html' % (PRIVATE_TEMPLATES, status)).Get(), |
| 443 'scheduled': scheduled, | 444 'scheduled': scheduled, |
| 444 'version': version | 445 'version': version |
| 445 } | 446 } |
| 446 | 447 |
| 447 def _GetAvailabilityTemplate(self): | 448 def _GetAvailabilityTemplate(self, is_enum=False): |
| 448 '''Gets availability for the current node and returns an appropriate | 449 '''Gets availability for the current node and returns an appropriate |
| 449 template object. | 450 template object. |
| 450 ''' | 451 ''' |
| 452 # We don't show an availability warning for enums. |
| 453 # TODO(devlin): We should also render enums differently, indicating that |
| 454 # symbolic constants are available from version 44 onwards. |
| 455 if is_enum: |
| 456 return None |
| 457 |
| 451 # Displaying deprecated status takes precedence over when the API | 458 # Displaying deprecated status takes precedence over when the API |
| 452 # became stable. | 459 # became stable. |
| 453 availability_info = self._current_node.GetDeprecated() | 460 availability_info = self._current_node.GetDeprecated() |
| 454 if availability_info is not None: | 461 if availability_info is not None: |
| 455 status = 'deprecated' | 462 status = 'deprecated' |
| 456 else: | 463 else: |
| 457 availability_info = self._current_node.GetAvailability() | 464 availability_info = self._current_node.GetAvailability() |
| 458 if availability_info is None: | 465 if availability_info is None: |
| 459 return None | 466 return None |
| 460 status = availability_info.channel_info.channel | 467 status = availability_info.channel_info.channel |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 622 request): | 629 request): |
| 623 return _JSCViewBuilder(content_script_apis, | 630 return _JSCViewBuilder(content_script_apis, |
| 624 jsc_model, | 631 jsc_model, |
| 625 availability_finder, | 632 availability_finder, |
| 626 json_cache, | 633 json_cache, |
| 627 template_cache, | 634 template_cache, |
| 628 features_bundle, | 635 features_bundle, |
| 629 event_byname_future, | 636 event_byname_future, |
| 630 platform, | 637 platform, |
| 631 samples).ToDict(request) | 638 samples).ToDict(request) |
| OLD | NEW |