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

Side by Side Diff: tools/dom/scripts/htmldartgenerator.py

Issue 11887006: Changed @domName annotation in comment to full fledge @DomName annotation. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Merged and stuff.' Created 7 years, 11 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 #!/usr/bin/python 1 #!/usr/bin/python
2 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 2 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
3 # for details. All rights reserved. Use of this source code is governed by a 3 # for details. All rights reserved. Use of this source code is governed by a
4 # BSD-style license that can be found in the LICENSE file. 4 # BSD-style license that can be found in the LICENSE file.
5 5
6 """This module provides shared functionality for the system to generate 6 """This module provides shared functionality for the system to generate
7 dart:html APIs from the IDL database.""" 7 dart:html APIs from the IDL database."""
8 8
9 from generator import AnalyzeOperation, ConstantOutputOrder, \ 9 from generator import AnalyzeOperation, ConstantOutputOrder, \
10 DartDomNameOfAttribute, FindMatchingAttribute, IsDartCollectionType, \ 10 DartDomNameOfAttribute, FindMatchingAttribute, IsDartCollectionType, \
(...skipping 23 matching lines...) Expand all
34 support_check = self.GetSupportCheck() 34 support_check = self.GetSupportCheck()
35 self._members_emitter.Emit('\n' 35 self._members_emitter.Emit('\n'
36 ' /// Checks if this type is supported on the current platform.\n' 36 ' /// Checks if this type is supported on the current platform.\n'
37 ' static bool get supported => $SUPPORT_CHECK;\n', 37 ' static bool get supported => $SUPPORT_CHECK;\n',
38 SUPPORT_CHECK=support_check) 38 SUPPORT_CHECK=support_check)
39 39
40 def EmitAttributeDocumentation(self, attribute): 40 def EmitAttributeDocumentation(self, attribute):
41 """ Emits the MDN dartdoc comment for an attribute. 41 """ Emits the MDN dartdoc comment for an attribute.
42 """ 42 """
43 dom_name = DartDomNameOfAttribute(attribute) 43 dom_name = DartDomNameOfAttribute(attribute)
44 self._members_emitter.Emit('\n /// @domName $DOMINTERFACE.$DOMNAME;' 44 self._members_emitter.Emit('\n /// @docsEditable true',
45 ' @docsEditable true',
46 DOMINTERFACE=attribute.doc_js_interface_name, 45 DOMINTERFACE=attribute.doc_js_interface_name,
47 DOMNAME=dom_name) 46 DOMNAME=dom_name)
48 47
49 def EmitOperationDocumentation(self, operation): 48 def EmitOperationDocumentation(self, operation):
50 """ Emits the MDN dartdoc comment for an operation. 49 """ Emits the MDN dartdoc comment for an operation.
51 """ 50 """
52 self._members_emitter.Emit('\n /// @domName $DOMINTERFACE.$DOMNAME;' 51 self._members_emitter.Emit('\n /// @docsEditable true',
53 ' @docsEditable true',
54 DOMINTERFACE=operation.overloads[0].doc_js_interface_name, 52 DOMINTERFACE=operation.overloads[0].doc_js_interface_name,
55 DOMNAME=operation.name) 53 DOMNAME=operation.name)
56 54
57 def EmitEventGetter(self, events_class_name): 55 def EmitEventGetter(self, events_class_name):
58 self._members_emitter.Emit( 56 self._members_emitter.Emit(
59 '\n /// @domName EventTarget.addEventListener, ' 57 '\n /// @docsEditable true'
60 'EventTarget.removeEventListener, EventTarget.dispatchEvent;' 58 '\n @DomName("EventTarget.addEventListener, '
61 ' @docsEditable true' 59 'EventTarget.removeEventListener, EventTarget.dispatchEvent")'
62 '\n $TYPE get on =>\n new $TYPE(this);\n', 60 '\n $TYPE get on =>\n new $TYPE(this);\n',
63 TYPE=events_class_name) 61 TYPE=events_class_name)
64 62
65 def AddMembers(self, interface, declare_only=False): 63 def AddMembers(self, interface, declare_only=False):
66 for const in sorted(interface.constants, ConstantOutputOrder): 64 for const in sorted(interface.constants, ConstantOutputOrder):
67 self.AddConstant(const) 65 self.AddConstant(const)
68 66
69 for attr in sorted(interface.attributes, ConstantOutputOrder): 67 for attr in sorted(interface.attributes, ConstantOutputOrder):
70 if attr.type.id != 'EventListener': 68 if attr.type.id != 'EventListener':
71 self.AddAttribute(attr, declare_only) 69 self.AddAttribute(attr, declare_only)
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 '\n' 284 '\n'
287 ' factory $CTOR.fromBuffer(ArrayBuffer buffer, ' 285 ' factory $CTOR.fromBuffer(ArrayBuffer buffer, '
288 '[int byteOffset, int length]) => \n' 286 '[int byteOffset, int length]) => \n'
289 ' $FACTORY.create$(CTOR)_fromBuffer(buffer, byteOffset, length);\n' , 287 ' $FACTORY.create$(CTOR)_fromBuffer(buffer, byteOffset, length);\n' ,
290 CTOR=self._interface.id, 288 CTOR=self._interface.id,
291 TYPE=self._DartType(typed_array_type), 289 TYPE=self._DartType(typed_array_type),
292 FACTORY=factory_name) 290 FACTORY=factory_name)
293 291
294 def _AddConstructor(self, 292 def _AddConstructor(self,
295 constructor_info, factory_name, factory_constructor_name): 293 constructor_info, factory_name, factory_constructor_name):
296 self._members_emitter.Emit('\n ///@docsEditable true'); 294 self._members_emitter.Emit('\n /// @docsEditable true');
297 295
298 if not factory_constructor_name: 296 if not factory_constructor_name:
299 factory_constructor_name = '_create' 297 factory_constructor_name = '_create'
300 factory_parameters = constructor_info.ParametersAsArgumentList() 298 factory_parameters = constructor_info.ParametersAsArgumentList()
301 has_factory_provider = True 299 has_factory_provider = True
302 else: 300 else:
303 factory_parameters = ', '.join(constructor_info.factory_parameters) 301 factory_parameters = ', '.join(constructor_info.factory_parameters)
304 has_factory_provider = False 302 has_factory_provider = False
305 303
306 has_optional = any(param_info.is_optional 304 has_optional = any(param_info.is_optional
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 walk(interface.parents) 460 walk(interface.parents)
463 else: 461 else:
464 walk(interface.parents[1:]) 462 walk(interface.parents[1:])
465 return result 463 return result
466 464
467 def _DartType(self, type_name): 465 def _DartType(self, type_name):
468 return self._type_registry.DartType(type_name) 466 return self._type_registry.DartType(type_name)
469 467
470 def _IsPrivate(self, name): 468 def _IsPrivate(self, name):
471 return name.startswith('_') 469 return name.startswith('_')
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698