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

Side by Side Diff: tools/json_schema_compiler/idl_schema.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 #! /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
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 sys.exit('Did not process %s %s' % (child.cls, child))
not at google - send to devlin 2013/10/28 18:00:25 sys.exit to signal errors!? (aware that other plac
Sam McNally 2013/10/29 00:39:02 Done.
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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 Dump a json serialization of parse result for the IDL files whose names 422 Dump a json serialization of parse result for the IDL files whose names
417 were passed in on the command line. 423 were passed in on the command line.
418 ''' 424 '''
419 for filename in sys.argv[1:]: 425 for filename in sys.argv[1:]:
420 schema = Load(filename) 426 schema = Load(filename)
421 print json.dumps(schema, indent=2) 427 print json.dumps(schema, indent=2)
422 428
423 429
424 if __name__ == '__main__': 430 if __name__ == '__main__':
425 Main() 431 Main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698