| OLD | NEW |
| 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 import traceback |
| 7 | 7 |
| 8 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 |
| 9 from reference_resolver import ReferenceResolver | 9 from reference_resolver import ReferenceResolver |
| 10 from compiled_file_system import CompiledFileSystem | 10 from compiled_file_system import CompiledFileSystem |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 '''Replace '$ref's that refer to inline_docs with the json for those docs. | 119 '''Replace '$ref's that refer to inline_docs with the json for those docs. |
| 120 If |retain_inlined_types| is False, then the inlined nodes are removed | 120 If |retain_inlined_types| is False, then the inlined nodes are removed |
| 121 from the schema. | 121 from the schema. |
| 122 ''' | 122 ''' |
| 123 inline_docs = {} | 123 inline_docs = {} |
| 124 types_without_inline_doc = [] | 124 types_without_inline_doc = [] |
| 125 internal_api = False | 125 internal_api = False |
| 126 | 126 |
| 127 api_features = self._features_bundle.GetAPIFeatures().Get() | 127 api_features = self._features_bundle.GetAPIFeatures().Get() |
| 128 # We don't want to inline the events API, as it's handled differently | 128 # We don't want to inline the events API, as it's handled differently |
| 129 if schema.get('namespace', '') != 'events': | 129 # Also, the webviewTag API is handled differently, as it only exists |
| 130 # for the purpose of documentation, it's not a true internal api |
| 131 namespace = schema.get('namespace', '') |
| 132 if namespace != 'events' and namespace != 'webviewTag': |
| 130 internal_api = api_features.get(schema.get('namespace', ''), {}).get( | 133 internal_api = api_features.get(schema.get('namespace', ''), {}).get( |
| 131 'internal', False) | 134 'internal', False) |
| 132 | 135 |
| 133 api_refs = set() | 136 api_refs = set() |
| 134 # Gather refs to internal APIs | 137 # Gather refs to internal APIs |
| 135 def gather_api_refs(node): | 138 def gather_api_refs(node): |
| 136 if isinstance(node, list): | 139 if isinstance(node, list): |
| 137 for i in node: | 140 for i in node: |
| 138 gather_api_refs(i) | 141 gather_api_refs(i) |
| 139 elif isinstance(node, Mapping): | 142 elif isinstance(node, Mapping): |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 try: | 232 try: |
| 230 schemas = json_parse.Parse(file_data) | 233 schemas = json_parse.Parse(file_data) |
| 231 except: | 234 except: |
| 232 raise ValueError('Cannot parse "%s" as JSON:\n%s' % | 235 raise ValueError('Cannot parse "%s" as JSON:\n%s' % |
| 233 (path, traceback.format_exc())) | 236 (path, traceback.format_exc())) |
| 234 for schema in schemas: | 237 for schema in schemas: |
| 235 # Schemas could consist of one API schema (data for a specific API file) | 238 # Schemas could consist of one API schema (data for a specific API file) |
| 236 # or multiple (data from extension_api.json). | 239 # or multiple (data from extension_api.json). |
| 237 trim_and_inline(schema) | 240 trim_and_inline(schema) |
| 238 return schemas | 241 return schemas |
| OLD | NEW |