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

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

Issue 406933003: Docserver: Show callback parameters in all callback references. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase/Address comment Created 6 years, 5 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
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 from copy import copy 5 from copy import copy
6 import logging 6 import logging
7 import os 7 import os
8 import posixpath 8 import posixpath
9 9
10 from data_source import DataSource 10 from data_source import DataSource
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 self._AddCommonProperties(function_dict, function) 375 self._AddCommonProperties(function_dict, function)
376 if function.returns: 376 if function.returns:
377 function_dict['returns'] = self._GenerateType(function.returns) 377 function_dict['returns'] = self._GenerateType(function.returns)
378 with self._current_node.Descend(function.simple_name): 378 with self._current_node.Descend(function.simple_name):
379 with self._current_node.Descend('parameters'): 379 with self._current_node.Descend('parameters'):
380 for param in function.params: 380 for param in function.params:
381 function_dict['parameters'].append(self._GenerateProperty(param)) 381 function_dict['parameters'].append(self._GenerateProperty(param))
382 if function.callback is not None: 382 if function.callback is not None:
383 # Show the callback as an extra parameter. 383 # Show the callback as an extra parameter.
384 function_dict['parameters'].append( 384 function_dict['parameters'].append(
385 self._GenerateCallbackProperty(function.callback)) 385 self._GenerateCallbackProperty(function.callback,
386 function_dict['callback']))
386 if len(function_dict['parameters']) > 0: 387 if len(function_dict['parameters']) > 0:
387 function_dict['parameters'][-1]['last'] = True 388 function_dict['parameters'][-1]['last'] = True
388 return function_dict 389 return function_dict
389 390
390 def _GenerateEvents(self, events): 391 def _GenerateEvents(self, events):
391 with self._current_node.Descend('events'): 392 with self._current_node.Descend('events'):
392 return [self._GenerateEvent(e) for e in events.values() 393 return [self._GenerateEvent(e) for e in events.values()
393 if not e.supports_dom] 394 if not e.supports_dom]
394 395
395 def _GenerateDomEvents(self, events): 396 def _GenerateDomEvents(self, events):
(...skipping 26 matching lines...) Expand all
422 # information stored in |event|. 423 # information stored in |event|.
423 if event.supports_listeners: 424 if event.supports_listeners:
424 callback_object = model.Function(parent=event, 425 callback_object = model.Function(parent=event,
425 name='callback', 426 name='callback',
426 json={}, 427 json={},
427 namespace=event.parent, 428 namespace=event.parent,
428 origin='') 429 origin='')
429 callback_object.params = event.params 430 callback_object.params = event.params
430 if event.callback: 431 if event.callback:
431 callback_object.callback = event.callback 432 callback_object.callback = event.callback
432 callback_parameters = self._GenerateCallbackProperty(callback_object) 433 callback = self._GenerateFunction(callback_object)
434 callback_parameters = self._GenerateCallbackProperty(callback_object,
435 callback)
433 callback_parameters['last'] = True 436 callback_parameters['last'] = True
434 event_dict['byName']['addListener'] = { 437 event_dict['byName']['addListener'] = {
435 'name': 'addListener', 438 'name': 'addListener',
436 'callback': self._GenerateFunction(callback_object), 439 'callback': callback,
437 'parameters': [callback_parameters] 440 'parameters': [callback_parameters]
438 } 441 }
439 with self._current_node.Descend(event.simple_name, ignore=('properties',)): 442 with self._current_node.Descend(event.simple_name, ignore=('properties',)):
440 if event.supports_dom: 443 if event.supports_dom:
441 # Treat params as properties of the custom Event object associated with 444 # Treat params as properties of the custom Event object associated with
442 # this DOM Event. 445 # this DOM Event.
443 event_dict['properties'] += [self._GenerateProperty(param) 446 event_dict['properties'] += [self._GenerateProperty(param)
444 for param in event.params] 447 for param in event.params]
445 return event_dict 448 return event_dict
446 449
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 if value is not None: 510 if value is not None:
508 if isinstance(value, int): 511 if isinstance(value, int):
509 property_dict['value'] = _FormatValue(value) 512 property_dict['value'] = _FormatValue(value)
510 else: 513 else:
511 property_dict['value'] = value 514 property_dict['value'] = value
512 else: 515 else:
513 self._RenderTypeInformation(type_, property_dict) 516 self._RenderTypeInformation(type_, property_dict)
514 517
515 return property_dict 518 return property_dict
516 519
517 def _GenerateCallbackProperty(self, callback): 520 def _GenerateCallbackProperty(self, callback, callback_dict):
518 property_dict = { 521 property_dict = {
519 'name': callback.simple_name, 522 'name': callback.simple_name,
520 'description': callback.description, 523 'description': callback.description,
521 'optional': callback.optional, 524 'optional': callback.optional,
522 'is_callback': True, 525 'isCallback': True,
526 'asFunction': callback_dict,
523 'id': _CreateId(callback, 'property'), 527 'id': _CreateId(callback, 'property'),
524 'simple_type': 'function', 528 'simple_type': 'function',
525 } 529 }
526 if (callback.parent is not None and 530 if (callback.parent is not None and
527 not isinstance(callback.parent, model.Namespace)): 531 not isinstance(callback.parent, model.Namespace)):
528 property_dict['parentName'] = callback.parent.simple_name 532 property_dict['parentName'] = callback.parent.simple_name
529 return property_dict 533 return property_dict
530 534
531 def _RenderTypeInformation(self, type_, dst_dict): 535 def _RenderTypeInformation(self, type_, dst_dict):
532 with self._current_node.Descend(ignore=('types', 'properties')): 536 with self._current_node.Descend(ignore=('types', 'properties')):
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
815 getter = lambda: 0 819 getter = lambda: 0
816 getter.get = lambda api_name: self._GetImpl(platform, api_name).Get() 820 getter.get = lambda api_name: self._GetImpl(platform, api_name).Get()
817 return getter 821 return getter
818 822
819 def Cron(self): 823 def Cron(self):
820 futures = [] 824 futures = []
821 for platform in GetPlatforms(): 825 for platform in GetPlatforms():
822 futures += [self._GetImpl(platform, name) 826 futures += [self._GetImpl(platform, name)
823 for name in self._platform_bundle.GetAPIModels(platform).GetNames()] 827 for name in self._platform_bundle.GetAPIModels(platform).GetNames()]
824 return Collect(futures, except_pass=FileNotFoundError) 828 return Collect(futures, except_pass=FileNotFoundError)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698