OLD | NEW |
1 #! /usr/bin/env python | 1 #! /usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 import itertools | 6 import itertools |
7 import json | 7 import json |
8 import os.path | 8 import os.path |
9 import re | 9 import re |
10 import sys | 10 import sys |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 schema compiler expects to see. | 285 schema compiler expects to see. |
286 ''' | 286 ''' |
287 def __init__(self, enum_node): | 287 def __init__(self, enum_node): |
288 self.node = enum_node | 288 self.node = enum_node |
289 self.description = '' | 289 self.description = '' |
290 | 290 |
291 def process(self, callbacks): | 291 def process(self, callbacks): |
292 enum = [] | 292 enum = [] |
293 for node in self.node.children: | 293 for node in self.node.children: |
294 if node.cls == 'EnumItem': | 294 if node.cls == 'EnumItem': |
295 enum.append(node.GetName()) | 295 enum_value = {'name': node.GetName()} |
| 296 for child in node.children: |
| 297 if child.cls == 'Comment': |
| 298 enum_value['description'] = ProcessComment(child.GetName())[0] |
| 299 else: |
| 300 raise ValueError('Did not process %s %s' % (child.cls, child)) |
| 301 enum.append(enum_value) |
296 elif node.cls == 'Comment': | 302 elif node.cls == 'Comment': |
297 self.description = ProcessComment(node.GetName())[0] | 303 self.description = ProcessComment(node.GetName())[0] |
298 else: | 304 else: |
299 sys.exit('Did not process %s %s' % (node.cls, node)) | 305 sys.exit('Did not process %s %s' % (node.cls, node)) |
300 result = {'id' : self.node.GetName(), | 306 result = {'id' : self.node.GetName(), |
301 'description': self.description, | 307 'description': self.description, |
302 'type': 'string', | 308 'type': 'string', |
303 'enum': enum} | 309 'enum': enum} |
304 for property_name in ('inline_doc', 'noinline_doc', 'nodoc'): | 310 for property_name in ('inline_doc', 'noinline_doc', 'nodoc'): |
305 if self.node.GetProperty(property_name): | 311 if self.node.GetProperty(property_name): |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 Dump a json serialization of parse result for the IDL files whose names | 433 Dump a json serialization of parse result for the IDL files whose names |
428 were passed in on the command line. | 434 were passed in on the command line. |
429 ''' | 435 ''' |
430 for filename in sys.argv[1:]: | 436 for filename in sys.argv[1:]: |
431 schema = Load(filename) | 437 schema = Load(filename) |
432 print json.dumps(schema, indent=2) | 438 print json.dumps(schema, indent=2) |
433 | 439 |
434 | 440 |
435 if __name__ == '__main__': | 441 if __name__ == '__main__': |
436 Main() | 442 Main() |
OLD | NEW |