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 ''' |
451 # Displaying deprecated status takes precedence over when the API | 452 # Displaying deprecated status takes precedence over when the API |
452 # became stable. | 453 # became stable. |
453 availability_info = self._current_node.GetDeprecated() | 454 availability_info = self._current_node.GetDeprecated() |
454 if availability_info is not None: | 455 if availability_info is not None: |
455 status = 'deprecated' | 456 status = 'deprecated' |
457 # We don't show an availability warning for enums. | |
not at google - send to devlin
2015/04/08 18:05:17
If we *really* don't want to show availability war
Devlin
2015/04/08 19:44:02
Done, done, and done.
| |
458 elif is_enum: | |
459 return None | |
456 else: | 460 else: |
457 availability_info = self._current_node.GetAvailability() | 461 availability_info = self._current_node.GetAvailability() |
458 if availability_info is None: | 462 if availability_info is None: |
459 return None | 463 return None |
460 status = availability_info.channel_info.channel | 464 status = availability_info.channel_info.channel |
461 return self._CreateAvailabilityTemplate( | 465 return self._CreateAvailabilityTemplate( |
462 status, | 466 status, |
463 availability_info.scheduled, | 467 availability_info.scheduled, |
464 availability_info.channel_info.version) | 468 availability_info.channel_info.version) |
465 | 469 |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
622 request): | 626 request): |
623 return _JSCViewBuilder(content_script_apis, | 627 return _JSCViewBuilder(content_script_apis, |
624 jsc_model, | 628 jsc_model, |
625 availability_finder, | 629 availability_finder, |
626 json_cache, | 630 json_cache, |
627 template_cache, | 631 template_cache, |
628 features_bundle, | 632 features_bundle, |
629 event_byname_future, | 633 event_byname_future, |
630 platform, | 634 platform, |
631 samples).ToDict(request) | 635 samples).ToDict(request) |
OLD | NEW |