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

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

Issue 11195055: Extensions Docs Server: Fix handling of nodocs in server2 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 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 | chrome/common/extensions/docs/server2/api_data_source_test.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 = 0 20 _VERSION = 1
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):
Aaron Boodman 2012/10/24 22:25:02 Weird to assume that only dictionaries can have 'n
cduvall 2012/10/26 00:01:47 I don't see how a type besides a dictionary could
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 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 328
323 def get(self, key): 329 def get(self, key):
324 path, ext = os.path.splitext(key) 330 path, ext = os.path.splitext(key)
325 unix_name = model.UnixName(path) 331 unix_name = model.UnixName(path)
326 idl_names = self._idl_names_cache.GetFromFileListing(self._base_path) 332 idl_names = self._idl_names_cache.GetFromFileListing(self._base_path)
327 cache, ext = ((self._idl_cache, '.idl') if (unix_name in idl_names) else 333 cache, ext = ((self._idl_cache, '.idl') if (unix_name in idl_names) else
328 (self._json_cache, '.json')) 334 (self._json_cache, '.json'))
329 return self._GenerateHandlebarContext( 335 return self._GenerateHandlebarContext(
330 cache.GetFromFile('%s/%s%s' % (self._base_path, unix_name, ext)), 336 cache.GetFromFile('%s/%s%s' % (self._base_path, unix_name, ext)),
331 path) 337 path)
OLDNEW
« no previous file with comments | « no previous file | chrome/common/extensions/docs/server2/api_data_source_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698