| 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 json | 6 import json |
| 7 import os | 7 import os |
| 8 | 8 |
| 9 from docs_server_utils import GetLinkToRefType | 9 from docs_server_utils import GetLinkToRefType |
| 10 import compiled_file_system as compiled_fs | 10 import compiled_file_system as compiled_fs |
| 11 from file_system import FileNotFoundError | 11 from file_system import FileNotFoundError |
| 12 import third_party.json_schema_compiler.json_comment_eater as json_comment_eater | 12 import third_party.json_schema_compiler.json_comment_eater as json_comment_eater |
| 13 import third_party.json_schema_compiler.model as model | 13 import third_party.json_schema_compiler.model as model |
| 14 import third_party.json_schema_compiler.idl_schema as idl_schema | 14 import third_party.json_schema_compiler.idl_schema as idl_schema |
| 15 import third_party.json_schema_compiler.idl_parser as idl_parser | 15 import third_party.json_schema_compiler.idl_parser as idl_parser |
| 16 | 16 |
| 17 # Increment this version when there are changes to the data stored in any of | 17 # Increment this version when there are changes to the data stored in any of |
| 18 # the caches used by APIDataSource. This allows the cache to be invalidated | 18 # the caches used by APIDataSource. This allows the cache to be invalidated |
| 19 # without having to flush memcache on the production server. | 19 # without having to flush memcache on the production server. |
| 20 _VERSION = 1 | 20 _VERSION = 2 |
| 21 | 21 |
| 22 def _RemoveNoDocs(item): | 22 def _RemoveNoDocs(item): |
| 23 if type(item) == dict: | 23 if type(item) == dict: |
| 24 if item.get('nodoc', False): | 24 if item.get('nodoc', False): |
| 25 return True | 25 return True |
| 26 to_remove = [] |
| 26 for key, value in item.items(): | 27 for key, value in item.items(): |
| 27 if _RemoveNoDocs(value): | 28 if _RemoveNoDocs(value): |
| 28 del item[key] | 29 to_remove.append(key) |
| 30 for k in to_remove: |
| 31 del item[k] |
| 29 elif type(item) == list: | 32 elif type(item) == list: |
| 33 to_remove = [] |
| 30 for i in item: | 34 for i in item: |
| 31 if _RemoveNoDocs(i): | 35 if _RemoveNoDocs(i): |
| 32 item.remove(i) | 36 to_remove.append(i) |
| 37 for i in to_remove: |
| 38 item.remove(i) |
| 33 return False | 39 return False |
| 34 | 40 |
| 35 def _CreateId(node, prefix): | 41 def _CreateId(node, prefix): |
| 36 if node.parent is not None and not isinstance(node.parent, model.Namespace): | 42 if node.parent is not None and not isinstance(node.parent, model.Namespace): |
| 37 return '-'.join([prefix, node.parent.simple_name, node.simple_name]) | 43 return '-'.join([prefix, node.parent.simple_name, node.simple_name]) |
| 38 return '-'.join([prefix, node.simple_name]) | 44 return '-'.join([prefix, node.simple_name]) |
| 39 | 45 |
| 40 def _FormatValue(value): | 46 def _FormatValue(value): |
| 41 """Inserts commas every three digits for integer values. It is magic. | 47 """Inserts commas every three digits for integer values. It is magic. |
| 42 """ | 48 """ |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 | 334 |
| 329 def get(self, key): | 335 def get(self, key): |
| 330 path, ext = os.path.splitext(key) | 336 path, ext = os.path.splitext(key) |
| 331 unix_name = model.UnixName(path) | 337 unix_name = model.UnixName(path) |
| 332 idl_names = self._idl_names_cache.GetFromFileListing(self._base_path) | 338 idl_names = self._idl_names_cache.GetFromFileListing(self._base_path) |
| 333 cache, ext = ((self._idl_cache, '.idl') if (unix_name in idl_names) else | 339 cache, ext = ((self._idl_cache, '.idl') if (unix_name in idl_names) else |
| 334 (self._json_cache, '.json')) | 340 (self._json_cache, '.json')) |
| 335 return self._GenerateHandlebarContext( | 341 return self._GenerateHandlebarContext( |
| 336 cache.GetFromFile('%s/%s%s' % (self._base_path, unix_name, ext)), | 342 cache.GetFromFile('%s/%s%s' % (self._base_path, unix_name, ext)), |
| 337 path) | 343 path) |
| OLD | NEW |