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

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

Issue 18182010: Make html metadata follow the spec. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixed DocsEditable, Experimental, Unstable Created 7 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 | Annotate | Revision Log
« no previous file with comments | « tools/dom/docs/lib/docs.dart ('k') | tools/dom/scripts/htmldartgenerator.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 #!/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 to provide Dart metadata for 6 """This module provides shared functionality to provide Dart metadata for
7 DOM APIs. 7 DOM APIs.
8 """ 8 """
9 9
10 import copy 10 import copy
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 ], 292 ],
293 293
294 'XMLHttpRequest.response': [ 294 'XMLHttpRequest.response': [
295 "@Creates('ByteBuffer|Blob|Document|=Object|JSExtendableArray|String" 295 "@Creates('ByteBuffer|Blob|Document|=Object|JSExtendableArray|String"
296 "|num')", 296 "|num')",
297 ], 297 ],
298 }, dart2jsOnly=True) 298 }, dart2jsOnly=True)
299 299
300 _blink_experimental_annotations = [ 300 _blink_experimental_annotations = [
301 "@SupportedBrowser(SupportedBrowser.CHROME)", 301 "@SupportedBrowser(SupportedBrowser.CHROME)",
302 "@Experimental", 302 "@Experimental()",
303 ] 303 ]
304 304
305 _indexed_db_annotations = [ 305 _indexed_db_annotations = [
306 "@SupportedBrowser(SupportedBrowser.CHROME)", 306 "@SupportedBrowser(SupportedBrowser.CHROME)",
307 "@SupportedBrowser(SupportedBrowser.FIREFOX, '15')", 307 "@SupportedBrowser(SupportedBrowser.FIREFOX, '15')",
308 "@SupportedBrowser(SupportedBrowser.IE, '10')", 308 "@SupportedBrowser(SupportedBrowser.IE, '10')",
309 "@Experimental", 309 "@Experimental()",
310 ] 310 ]
311 311
312 _file_system_annotations = [ 312 _file_system_annotations = [
313 "@SupportedBrowser(SupportedBrowser.CHROME)", 313 "@SupportedBrowser(SupportedBrowser.CHROME)",
314 "@Experimental", 314 "@Experimental()",
315 ] 315 ]
316 316
317 _all_but_ie9_annotations = [ 317 _all_but_ie9_annotations = [
318 "@SupportedBrowser(SupportedBrowser.CHROME)", 318 "@SupportedBrowser(SupportedBrowser.CHROME)",
319 "@SupportedBrowser(SupportedBrowser.FIREFOX)", 319 "@SupportedBrowser(SupportedBrowser.FIREFOX)",
320 "@SupportedBrowser(SupportedBrowser.IE, '10')", 320 "@SupportedBrowser(SupportedBrowser.IE, '10')",
321 "@SupportedBrowser(SupportedBrowser.SAFARI)", 321 "@SupportedBrowser(SupportedBrowser.SAFARI)",
322 ] 322 ]
323 323
324 _history_annotations = _all_but_ie9_annotations 324 _history_annotations = _all_but_ie9_annotations
325 325
326 _no_ie_annotations = [ 326 _no_ie_annotations = [
327 "@SupportedBrowser(SupportedBrowser.CHROME)", 327 "@SupportedBrowser(SupportedBrowser.CHROME)",
328 "@SupportedBrowser(SupportedBrowser.FIREFOX)", 328 "@SupportedBrowser(SupportedBrowser.FIREFOX)",
329 "@SupportedBrowser(SupportedBrowser.SAFARI)", 329 "@SupportedBrowser(SupportedBrowser.SAFARI)",
330 ] 330 ]
331 331
332 _performance_annotations = [ 332 _performance_annotations = [
333 "@SupportedBrowser(SupportedBrowser.CHROME)", 333 "@SupportedBrowser(SupportedBrowser.CHROME)",
334 "@SupportedBrowser(SupportedBrowser.FIREFOX)", 334 "@SupportedBrowser(SupportedBrowser.FIREFOX)",
335 "@SupportedBrowser(SupportedBrowser.IE)", 335 "@SupportedBrowser(SupportedBrowser.IE)",
336 ] 336 ]
337 337
338 _rtc_annotations = [ # Note: Firefox nightly builds also support this. 338 _rtc_annotations = [ # Note: Firefox nightly builds also support this.
339 "@SupportedBrowser(SupportedBrowser.CHROME)", 339 "@SupportedBrowser(SupportedBrowser.CHROME)",
340 "@Experimental", 340 "@Experimental()",
341 ] 341 ]
342 342
343 _shadow_dom_annotations = [ 343 _shadow_dom_annotations = [
344 "@SupportedBrowser(SupportedBrowser.CHROME, '26')", 344 "@SupportedBrowser(SupportedBrowser.CHROME, '26')",
345 "@Experimental", 345 "@Experimental()",
346 ] 346 ]
347 347
348 _speech_recognition_annotations = [ 348 _speech_recognition_annotations = [
349 "@SupportedBrowser(SupportedBrowser.CHROME, '25')", 349 "@SupportedBrowser(SupportedBrowser.CHROME, '25')",
350 "@Experimental", 350 "@Experimental()",
351 ] 351 ]
352 352
353 _svg_annotations = _all_but_ie9_annotations; 353 _svg_annotations = _all_but_ie9_annotations;
354 354
355 _web_sql_annotations = [ 355 _web_sql_annotations = [
356 "@SupportedBrowser(SupportedBrowser.CHROME)", 356 "@SupportedBrowser(SupportedBrowser.CHROME)",
357 "@SupportedBrowser(SupportedBrowser.SAFARI)", 357 "@SupportedBrowser(SupportedBrowser.SAFARI)",
358 "@Experimental", 358 "@Experimental()",
359 ] 359 ]
360 360
361 _webgl_annotations = [ 361 _webgl_annotations = [
362 "@SupportedBrowser(SupportedBrowser.CHROME)", 362 "@SupportedBrowser(SupportedBrowser.CHROME)",
363 "@SupportedBrowser(SupportedBrowser.FIREFOX)", 363 "@SupportedBrowser(SupportedBrowser.FIREFOX)",
364 "@Experimental", 364 "@Experimental()",
365 ] 365 ]
366 366
367 _webkit_experimental_annotations = [ 367 _webkit_experimental_annotations = [
368 "@SupportedBrowser(SupportedBrowser.CHROME)", 368 "@SupportedBrowser(SupportedBrowser.CHROME)",
369 "@SupportedBrowser(SupportedBrowser.SAFARI)", 369 "@SupportedBrowser(SupportedBrowser.SAFARI)",
370 "@Experimental", 370 "@Experimental()",
371 ] 371 ]
372 372
373 # Annotations to be placed on generated members. 373 # Annotations to be placed on generated members.
374 # The table is indexed as: 374 # The table is indexed as:
375 # INTERFACE: annotations to be added to the interface declaration 375 # INTERFACE: annotations to be added to the interface declaration
376 # INTERFACE.MEMBER: annotation to be added to the member declaration 376 # INTERFACE.MEMBER: annotation to be added to the member declaration
377 _annotations = monitored.Dict('dartmetadata._annotations', { 377 _annotations = monitored.Dict('dartmetadata._annotations', {
378 'CSSHostRule': _shadow_dom_annotations, 378 'CSSHostRule': _shadow_dom_annotations,
379 'CSSMatrix': _webkit_experimental_annotations, 379 'CSSMatrix': _webkit_experimental_annotations,
380 'Crypto': _webkit_experimental_annotations, 380 'Crypto': _webkit_experimental_annotations,
(...skipping 13 matching lines...) Expand all
394 'DOMWindow.webkitConvertPointFromPageToNode': _webkit_experimental_annotations , 394 'DOMWindow.webkitConvertPointFromPageToNode': _webkit_experimental_annotations ,
395 'DOMWindow.indexedDB': _indexed_db_annotations, 395 'DOMWindow.indexedDB': _indexed_db_annotations,
396 'DOMWindow.openDatabase': _web_sql_annotations, 396 'DOMWindow.openDatabase': _web_sql_annotations,
397 'DOMWindow.performance': _performance_annotations, 397 'DOMWindow.performance': _performance_annotations,
398 'DOMWindow.webkitNotifications': _webkit_experimental_annotations, 398 'DOMWindow.webkitNotifications': _webkit_experimental_annotations,
399 'DOMWindow.webkitRequestFileSystem': _file_system_annotations, 399 'DOMWindow.webkitRequestFileSystem': _file_system_annotations,
400 'DOMWindow.webkitResolveLocalFileSystemURL': _file_system_annotations, 400 'DOMWindow.webkitResolveLocalFileSystemURL': _file_system_annotations,
401 'Element.ontransitionend': _all_but_ie9_annotations, 401 'Element.ontransitionend': _all_but_ie9_annotations,
402 # Placeholder to add experimental flag, implementation for this is 402 # Placeholder to add experimental flag, implementation for this is
403 # pending in a separate CL. 403 # pending in a separate CL.
404 'Element.webkitMatchesSelector': ['@Experimental()'], 404 'Element.webkitMatchesSelector': ['@Experimental()()'],
405 'Element.webkitCreateShadowRoot': [ 405 'Element.webkitCreateShadowRoot': [
406 "@SupportedBrowser(SupportedBrowser.CHROME, '25')", 406 "@SupportedBrowser(SupportedBrowser.CHROME, '25')",
407 "@Experimental", 407 "@Experimental()",
408 ], 408 ],
409 'Event.clipboardData': _webkit_experimental_annotations, 409 'Event.clipboardData': _webkit_experimental_annotations,
410 'FormData': _all_but_ie9_annotations, 410 'FormData': _all_but_ie9_annotations,
411 'HashChangeEvent': [ 411 'HashChangeEvent': [
412 "@SupportedBrowser(SupportedBrowser.CHROME)", 412 "@SupportedBrowser(SupportedBrowser.CHROME)",
413 "@SupportedBrowser(SupportedBrowser.FIREFOX)", 413 "@SupportedBrowser(SupportedBrowser.FIREFOX)",
414 "@SupportedBrowser(SupportedBrowser.SAFARI)", 414 "@SupportedBrowser(SupportedBrowser.SAFARI)",
415 ], 415 ],
416 'History.pushState': _history_annotations, 416 'History.pushState': _history_annotations,
417 'History.replaceState': _history_annotations, 417 'History.replaceState': _history_annotations,
(...skipping 24 matching lines...) Expand all
442 'IDBFactory': _indexed_db_annotations, 442 'IDBFactory': _indexed_db_annotations,
443 'IDBDatabase': _indexed_db_annotations, 443 'IDBDatabase': _indexed_db_annotations,
444 'MediaStream': _rtc_annotations, 444 'MediaStream': _rtc_annotations,
445 'MediaStreamEvent': _rtc_annotations, 445 'MediaStreamEvent': _rtc_annotations,
446 'MediaStreamTrack': _rtc_annotations, 446 'MediaStreamTrack': _rtc_annotations,
447 'MediaStreamTrackEvent': _rtc_annotations, 447 'MediaStreamTrackEvent': _rtc_annotations,
448 'MutationObserver': [ 448 'MutationObserver': [
449 "@SupportedBrowser(SupportedBrowser.CHROME)", 449 "@SupportedBrowser(SupportedBrowser.CHROME)",
450 "@SupportedBrowser(SupportedBrowser.FIREFOX)", 450 "@SupportedBrowser(SupportedBrowser.FIREFOX)",
451 "@SupportedBrowser(SupportedBrowser.SAFARI)", 451 "@SupportedBrowser(SupportedBrowser.SAFARI)",
452 "@Experimental", 452 "@Experimental()",
453 ], 453 ],
454 'NotificationCenter': _webkit_experimental_annotations, 454 'NotificationCenter': _webkit_experimental_annotations,
455 'Performance': _performance_annotations, 455 'Performance': _performance_annotations,
456 'PopStateEvent': _history_annotations, 456 'PopStateEvent': _history_annotations,
457 'RTCIceCandidate': _rtc_annotations, 457 'RTCIceCandidate': _rtc_annotations,
458 'RTCPeerConnection': _rtc_annotations, 458 'RTCPeerConnection': _rtc_annotations,
459 'RTCSessionDescription': _rtc_annotations, 459 'RTCSessionDescription': _rtc_annotations,
460 'ShadowRoot': _shadow_dom_annotations, 460 'ShadowRoot': _shadow_dom_annotations,
461 'SpeechRecognition': _speech_recognition_annotations, 461 'SpeechRecognition': _speech_recognition_annotations,
462 'SpeechRecognitionAlternative': _speech_recognition_annotations, 462 'SpeechRecognitionAlternative': _speech_recognition_annotations,
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 dom_name = '%s.%s' % (interface.javascript_binding_name, member_name) 583 dom_name = '%s.%s' % (interface.javascript_binding_name, member_name)
584 else: 584 else:
585 key = interface.id 585 key = interface.id
586 dom_name = interface.javascript_binding_name 586 dom_name = interface.javascript_binding_name
587 587
588 annotations = ["@DomName('" + dom_name + "')"] 588 annotations = ["@DomName('" + dom_name + "')"]
589 589
590 # Only add this for members, so we don't add DocsEditable to templated 590 # Only add this for members, so we don't add DocsEditable to templated
591 # classes (they get it from the default class template) 591 # classes (they get it from the default class template)
592 if member_name: 592 if member_name:
593 annotations.append('@DocsEditable'); 593 annotations.append('@DocsEditable()');
594 594
595 if key in _annotations: 595 if key in _annotations:
596 annotations.extend(_annotations[key]) 596 annotations.extend(_annotations[key])
597 597
598 if (not member_name and 598 if (not member_name and
599 interface.javascript_binding_name.startswith('WebKit') and 599 interface.javascript_binding_name.startswith('WebKit') and
600 interface.id not in html_interface_renames): 600 interface.id not in html_interface_renames):
601 annotations.extend(_webkit_experimental_annotations) 601 annotations.extend(_webkit_experimental_annotations)
602 602
603 if (member_name and member_name.startswith('webkit') and 603 if (member_name and member_name.startswith('webkit') and
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
710 support_level = support_info.get('support_level') 710 support_level = support_info.get('support_level')
711 comment = support_info.get('comment') 711 comment = support_info.get('comment')
712 annotations = [] 712 annotations = []
713 # TODO(blois): should add an annotation for the comment, but keeping out 713 # TODO(blois): should add an annotation for the comment, but keeping out
714 # to keep the initial diff a bit more localized. 714 # to keep the initial diff a bit more localized.
715 #if comment: 715 #if comment:
716 # annotations.append('// %s' % comment) 716 # annotations.append('// %s' % comment)
717 717
718 if dart_action: 718 if dart_action:
719 if dart_action == 'unstable': 719 if dart_action == 'unstable':
720 annotations.append('@Unstable') 720 annotations.append('@Unstable()')
721 elif dart_action == 'experimental': 721 elif dart_action == 'experimental':
722 if comment: 722 if comment:
723 annotations.append('// %s' % comment) 723 annotations.append('// %s' % comment)
724 annotations.append('@Experimental // %s' % support_level) 724 annotations.append('@Experimental() // %s' % support_level)
725 elif dart_action == 'suppress': 725 elif dart_action == 'suppress':
726 if comment: 726 if comment:
727 annotations.append('// %s' % comment) 727 annotations.append('// %s' % comment)
728 annotations.append('@deprecated // %s' % support_level) 728 annotations.append('@deprecated // %s' % support_level)
729 # TODO (blois): suppress generation of these APIs as a separate CL. 729 # TODO (blois): suppress generation of these APIs as a separate CL.
730 pass 730 pass
731 elif dart_action == 'stable': 731 elif dart_action == 'stable':
732 pass 732 pass
733 else: 733 else:
734 _logger.warn('Unknown dart_action - %s:%s' % (interface_id, member_id)) 734 _logger.warn('Unknown dart_action - %s:%s' % (interface_id, member_id))
735 elif support_level == 'untriaged': 735 elif support_level == 'untriaged':
736 annotations.append('@Experimental // untriaged') 736 annotations.append('@Experimental() // untriaged')
737 elif support_level == 'experimental': 737 elif support_level == 'experimental':
738 if comment: 738 if comment:
739 annotations.append('// %s' % comment) 739 annotations.append('// %s' % comment)
740 annotations.append('@Experimental') 740 annotations.append('@Experimental()')
741 elif support_level == 'nonstandard': 741 elif support_level == 'nonstandard':
742 if comment: 742 if comment:
743 annotations.append('// %s' % comment) 743 annotations.append('// %s' % comment)
744 annotations.append('@Experimental // non-standard') 744 annotations.append('@Experimental() // non-standard')
745 elif support_level == 'stable': 745 elif support_level == 'stable':
746 pass 746 pass
747 elif support_level == 'deprecated': 747 elif support_level == 'deprecated':
748 if comment: 748 if comment:
749 annotations.append('// %s' % comment) 749 annotations.append('// %s' % comment)
750 annotations.append('@deprecated') 750 annotations.append('@deprecated')
751 elif support_level is None: 751 elif support_level is None:
752 pass 752 pass
753 else: 753 else:
754 _logger.warn('Unknown support_level - %s:%s' % (interface_id, member_id)) 754 _logger.warn('Unknown support_level - %s:%s' % (interface_id, member_id))
755 755
756 return annotations 756 return annotations
757 757
758 def Flush(self): 758 def Flush(self):
759 json_file = open(self._api_status_path, 'w+') 759 json_file = open(self._api_status_path, 'w+')
760 json.dump(self._types, json_file, indent=2, separators=(',', ': '), sort_key s=True) 760 json.dump(self._types, json_file, indent=2, separators=(',', ': '), sort_key s=True)
761 json_file.close() 761 json_file.close()
OLDNEW
« no previous file with comments | « tools/dom/docs/lib/docs.dart ('k') | tools/dom/scripts/htmldartgenerator.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698