Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(904)

Side by Side Diff: tools/json_schema_compiler/model.py

Issue 39113003: Docserver: Display enum value descriptions in API docs. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 os.path 5 import os.path
6 6
7 from json_parse import OrderedDict 7 from json_parse import OrderedDict
8 from memoize import memoize 8 from memoize import memoize
9 9
10 class ParseException(Exception): 10 class ParseException(Exception):
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 json_type = json.get('type', None) 134 json_type = json.get('type', None)
135 if json_type == 'array': 135 if json_type == 'array':
136 self.property_type = PropertyType.ARRAY 136 self.property_type = PropertyType.ARRAY
137 self.item_type = Type( 137 self.item_type = Type(
138 self, '%sType' % name, json['items'], namespace, origin) 138 self, '%sType' % name, json['items'], namespace, origin)
139 elif '$ref' in json: 139 elif '$ref' in json:
140 self.property_type = PropertyType.REF 140 self.property_type = PropertyType.REF
141 self.ref_type = json['$ref'] 141 self.ref_type = json['$ref']
142 elif 'enum' in json and json_type == 'string': 142 elif 'enum' in json and json_type == 'string':
143 self.property_type = PropertyType.ENUM 143 self.property_type = PropertyType.ENUM
144 self.enum_values = [value for value in json['enum']] 144 self.enum_values = []
145 for enum_value in json['enum']:
146 if not isinstance(enum_value, dict):
147 enum_value = {'name': enum_value}
148 self.enum_values.append(enum_value)
not at google - send to devlin 2013/10/28 18:00:25 Rather than users of Model have to access enum['na
Sam McNally 2013/10/29 00:39:02 Done.
145 elif json_type == 'any': 149 elif json_type == 'any':
146 self.property_type = PropertyType.ANY 150 self.property_type = PropertyType.ANY
147 elif json_type == 'binary': 151 elif json_type == 'binary':
148 self.property_type = PropertyType.BINARY 152 self.property_type = PropertyType.BINARY
149 elif json_type == 'boolean': 153 elif json_type == 'boolean':
150 self.property_type = PropertyType.BOOLEAN 154 self.property_type = PropertyType.BOOLEAN
151 elif json_type == 'integer': 155 elif json_type == 'integer':
152 self.property_type = PropertyType.INTEGER 156 self.property_type = PropertyType.INTEGER
153 elif (json_type == 'double' or 157 elif (json_type == 'double' or
154 json_type == 'number'): 158 json_type == 'number'):
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 def _GetPlatforms(json): 492 def _GetPlatforms(json):
489 if 'platforms' not in json: 493 if 'platforms' not in json:
490 return None 494 return None
491 platforms = [] 495 platforms = []
492 for platform_name in json['platforms']: 496 for platform_name in json['platforms']:
493 for platform_enum in _Enum.GetAll(Platforms): 497 for platform_enum in _Enum.GetAll(Platforms):
494 if platform_name == platform_enum.name: 498 if platform_name == platform_enum.name:
495 platforms.append(platform_enum) 499 platforms.append(platform_enum)
496 break 500 break
497 return platforms 501 return platforms
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698