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

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

Issue 11195058: Extensions Docs Server: Show parameters of functions that are properties of an object (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
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
Aaron Boodman 2012/10/24 22:29:24 Note that this conflicts with: http://codereview.c
cduvall 2012/10/25 23:42:02 Yeah, this number only needs to change once per se
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 for key, value in item.items(): 26 for key, value in item.items():
27 if _RemoveNoDocs(value): 27 if _RemoveNoDocs(value):
28 del item[key] 28 del item[key]
29 elif type(item) == list: 29 elif type(item) == list:
30 for i in item: 30 for i in item:
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 def _GenerateProperties(self, properties): 173 def _GenerateProperties(self, properties):
174 return [self._GenerateProperty(v) for v in properties.values() 174 return [self._GenerateProperty(v) for v in properties.values()
175 if v.type_ != model.PropertyType.ADDITIONAL_PROPERTIES] 175 if v.type_ != model.PropertyType.ADDITIONAL_PROPERTIES]
176 176
177 def _GenerateProperty(self, property_): 177 def _GenerateProperty(self, property_):
178 property_dict = { 178 property_dict = {
179 'name': property_.simple_name, 179 'name': property_.simple_name,
180 'optional': property_.optional, 180 'optional': property_.optional,
181 'description': self._FormatDescription(property_.description), 181 'description': self._FormatDescription(property_.description),
182 'properties': self._GenerateProperties(property_.properties), 182 'properties': self._GenerateProperties(property_.properties),
183 'parameters': [],
183 'functions': self._GenerateFunctions(property_.functions), 184 'functions': self._GenerateFunctions(property_.functions),
184 'id': _CreateId(property_, 'property') 185 'id': _CreateId(property_, 'property')
185 } 186 }
187 for param in property_.params:
188 property_dict['parameters'].append(self._GenerateProperty(param))
186 if (property_.parent is not None and 189 if (property_.parent is not None and
187 not isinstance(property_.parent, model.Namespace)): 190 not isinstance(property_.parent, model.Namespace)):
188 property_dict['parent_name'] = property_.parent.simple_name 191 property_dict['parent_name'] = property_.parent.simple_name
189 else: 192 else:
190 property_dict['parent_name'] = None 193 property_dict['parent_name'] = None
191 if property_.has_value: 194 if property_.has_value:
192 if isinstance(property_.value, int): 195 if isinstance(property_.value, int):
193 property_dict['value'] = _FormatValue(property_.value) 196 property_dict['value'] = _FormatValue(property_.value)
194 else: 197 else:
195 property_dict['value'] = property_.value 198 property_dict['value'] = property_.value
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 325
323 def get(self, key): 326 def get(self, key):
324 path, ext = os.path.splitext(key) 327 path, ext = os.path.splitext(key)
325 unix_name = model.UnixName(path) 328 unix_name = model.UnixName(path)
326 idl_names = self._idl_names_cache.GetFromFileListing(self._base_path) 329 idl_names = self._idl_names_cache.GetFromFileListing(self._base_path)
327 cache, ext = ((self._idl_cache, '.idl') if (unix_name in idl_names) else 330 cache, ext = ((self._idl_cache, '.idl') if (unix_name in idl_names) else
328 (self._json_cache, '.json')) 331 (self._json_cache, '.json'))
329 return self._GenerateHandlebarContext( 332 return self._GenerateHandlebarContext(
330 cache.GetFromFile('%s/%s%s' % (self._base_path, unix_name, ext)), 333 cache.GetFromFile('%s/%s%s' % (self._base_path, unix_name, ext)),
331 path) 334 path)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698