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

Side by Side Diff: chrome/common/extensions/docs/server2/schema_util.py

Issue 132853002: Show the path when a json file fails to parse. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 months 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 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 collections import defaultdict, Mapping 5 from collections import defaultdict, Mapping
6 import traceback
6 7
7 from third_party.json_schema_compiler import json_parse, idl_schema, idl_parser 8 from third_party.json_schema_compiler import json_parse, idl_schema, idl_parser
8 9
9 10
10 def RemoveNoDocs(item): 11 def RemoveNoDocs(item):
11 '''Removes nodes that should not be rendered from an API schema. 12 '''Removes nodes that should not be rendered from an API schema.
12 ''' 13 '''
13 if json_parse.IsDict(item): 14 if json_parse.IsDict(item):
14 if item.get('nodoc', False): 15 if item.get('nodoc', False):
15 return True 16 return True
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 if is_idl: 105 if is_idl:
105 DetectInlineableTypes(schema) 106 DetectInlineableTypes(schema)
106 InlineDocs(schema) 107 InlineDocs(schema)
107 return schema 108 return schema
108 109
109 if path.endswith('.idl'): 110 if path.endswith('.idl'):
110 idl = idl_schema.IDLSchema(idl_parser.IDLParser().ParseData(file_data)) 111 idl = idl_schema.IDLSchema(idl_parser.IDLParser().ParseData(file_data))
111 # Wrap the result in a list so that it behaves like JSON API data. 112 # Wrap the result in a list so that it behaves like JSON API data.
112 return [trim_and_inline(idl.process()[0], is_idl=True)] 113 return [trim_and_inline(idl.process()[0], is_idl=True)]
113 114
114 schemas = json_parse.Parse(file_data) 115 try:
116 schemas = json_parse.Parse(file_data)
117 except:
118 raise ValueError('Cannot parse "%s" as JSON:\n%s' %
119 (path, traceback.format_exc()))
115 for schema in schemas: 120 for schema in schemas:
116 # Schemas could consist of one API schema (data for a specific API file) 121 # Schemas could consist of one API schema (data for a specific API file)
117 # or multiple (data from extension_api.json). 122 # or multiple (data from extension_api.json).
118 trim_and_inline(schema) 123 trim_and_inline(schema)
119 return schemas 124 return schemas
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698