| OLD | NEW |
| 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 copy | 5 import copy |
| 6 import logging | 6 import logging |
| 7 import os | 7 import os |
| 8 | 8 |
| 9 from file_system import FileNotFoundError | 9 from file_system import FileNotFoundError |
| 10 import third_party.json_schema_compiler.json_parse as json_parse | 10 import third_party.json_schema_compiler.json_parse as json_parse |
| 11 import third_party.json_schema_compiler.model as model | 11 import third_party.json_schema_compiler.model as model |
| 12 import third_party.json_schema_compiler.idl_schema as idl_schema | 12 import third_party.json_schema_compiler.idl_schema as idl_schema |
| 13 import third_party.json_schema_compiler.idl_parser as idl_parser | 13 import third_party.json_schema_compiler.idl_parser as idl_parser |
| 14 | 14 |
| 15 # Increment this if the data model changes for APIDataSource. | 15 # Increment this if the data model changes for APIDataSource. |
| 16 # This would include changes to model.py in json_schema_compiler! | 16 # This would include changes to model.py in json_schema_compiler! |
| 17 _VERSION = 17 | 17 _VERSION = 17 |
| 18 | 18 |
| 19 def _RemoveNoDocs(item): | 19 def _RemoveNoDocs(item): |
| 20 if json_parse.IsDict(item): | 20 if json_parse.IsDict(item): |
| 21 if item.get('nodoc', False): | 21 if item.get('nodoc', False): |
| 22 return True | 22 return True |
| 23 to_remove = [] | |
| 24 for key, value in item.items(): | 23 for key, value in item.items(): |
| 25 if _RemoveNoDocs(value): | 24 if _RemoveNoDocs(value): |
| 26 to_remove.append(key) | 25 del item[key] |
| 27 for k in to_remove: | |
| 28 del item[k] | |
| 29 elif type(item) == list: | 26 elif type(item) == list: |
| 30 to_remove = [] | 27 to_remove = [] |
| 31 for i in item: | 28 for i in item: |
| 32 if _RemoveNoDocs(i): | 29 if _RemoveNoDocs(i): |
| 33 to_remove.append(i) | 30 to_remove.append(i) |
| 34 for i in to_remove: | 31 for i in to_remove: |
| 35 item.remove(i) | 32 item.remove(i) |
| 36 return False | 33 return False |
| 37 | 34 |
| 38 def _CreateId(node, prefix): | 35 def _CreateId(node, prefix): |
| (...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 448 if self._disable_refs: | 445 if self._disable_refs: |
| 449 cache, ext = ( | 446 cache, ext = ( |
| 450 (self._idl_cache_no_refs, '.idl') if (unix_name in idl_names) else | 447 (self._idl_cache_no_refs, '.idl') if (unix_name in idl_names) else |
| 451 (self._json_cache_no_refs, '.json')) | 448 (self._json_cache_no_refs, '.json')) |
| 452 else: | 449 else: |
| 453 cache, ext = ((self._idl_cache, '.idl') if (unix_name in idl_names) else | 450 cache, ext = ((self._idl_cache, '.idl') if (unix_name in idl_names) else |
| 454 (self._json_cache, '.json')) | 451 (self._json_cache, '.json')) |
| 455 return self._GenerateHandlebarContext( | 452 return self._GenerateHandlebarContext( |
| 456 cache.GetFromFile('%s/%s%s' % (self._base_path, unix_name, ext)), | 453 cache.GetFromFile('%s/%s%s' % (self._base_path, unix_name, ext)), |
| 457 path) | 454 path) |
| OLD | NEW |