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

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

Issue 12087112: Can now correctly add documentation to constructors. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 10 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/docs.json ('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 for systems to generate 6 """This module provides shared functionality for systems to generate
7 Dart APIs from the IDL database.""" 7 Dart APIs from the IDL database."""
8 8
9 import copy 9 import copy
10 import json 10 import json
(...skipping 801 matching lines...) Expand 10 before | Expand all | Expand 10 after
812 'WorkerContext.webkitResolveLocalFileSystemSyncURL': _file_system_annotations, 812 'WorkerContext.webkitResolveLocalFileSystemSyncURL': _file_system_annotations,
813 'WorkerContext.webkitResolveLocalFileSystemURL': _file_system_annotations, 813 'WorkerContext.webkitResolveLocalFileSystemURL': _file_system_annotations,
814 'XMLHttpRequestProgressEvent': _webkit_experimental_annotations, 814 'XMLHttpRequestProgressEvent': _webkit_experimental_annotations,
815 'XSLTProcessor': [ 815 'XSLTProcessor': [
816 "@SupportedBrowser(SupportedBrowser.CHROME)", 816 "@SupportedBrowser(SupportedBrowser.CHROME)",
817 "@SupportedBrowser(SupportedBrowser.FIREFOX)", 817 "@SupportedBrowser(SupportedBrowser.FIREFOX)",
818 "@SupportedBrowser(SupportedBrowser.SAFARI)", 818 "@SupportedBrowser(SupportedBrowser.SAFARI)",
819 ], 819 ],
820 } 820 }
821 821
822 def GetComments(interface_name, member_name=None, library_name=None): 822 def GetComments(library_name, interface_name, member_name=None):
blois 2013/01/31 23:10:25 better!
823 """ Finds all comments for the interface or member and returns a list. """ 823 """ Finds all comments for the interface or member and returns a list. """
824 824
825 # Add documentation from JSON. 825 # Add documentation from JSON.
826 comments = [] 826 comments = []
827 827
828 if library_name in _dom_json and interface_name in _dom_json[library_name]: 828 if library_name in _dom_json and interface_name in _dom_json[library_name]:
829 if member_name and (member_name in 829 if (member_name and 'members' in _dom_json[library_name][interface_name] and
830 _dom_json[library_name][interface_name]['members']): 830 (member_name in _dom_json[library_name][interface_name]['members'])):
831 comments = _dom_json[library_name][interface_name]['members'][member_name] 831 comments = _dom_json[library_name][interface_name]['members'][member_name]
832 elif 'comment' in _dom_json[library_name][interface_name]: 832 elif 'comment' in _dom_json[library_name][interface_name]:
833 comments = _dom_json[library_name][interface_name]['comment'] 833 comments = _dom_json[library_name][interface_name]['comment']
834 834
835 if (len(comments)): 835 if (len(comments)):
836 comments = ['\n'.join(comments)] 836 comments = ['\n'.join(comments)]
837 837
838 return comments 838 return comments
839 839
840 def GetAnnotationsAndComments(interface_name, member_name=None, 840 def GetAnnotationsAndComments(library_name, interface_name, member_name=None):
841 library_name=None): 841 annotations = GetComments(library_name, interface_name, member_name)
842 annotations = GetComments(interface_name, member_name, library_name) 842 annotations = annotations + (FindCommonAnnotations(library_name, interface_nam e,
843 annotations = annotations + (FindCommonAnnotations(interface_name, 843 member_name))
844 member_name,
845 library_name))
846 844
847 return annotations 845 return annotations
848 846
849 def FindCommonAnnotations(interface_name, member_name=None, library_name=None): 847 def FindCommonAnnotations(library_name, interface_name, member_name=None):
850 """ Finds annotations common between dart2js and dartium. 848 """ Finds annotations common between dart2js and dartium.
851 """ 849 """
852 if member_name: 850 if member_name:
853 key = '%s.%s' % (interface_name, member_name) 851 key = '%s.%s' % (interface_name, member_name)
854 else: 852 else:
855 key = interface_name 853 key = interface_name
856 854
857 annotations = ["@DomName('" + key + "')"] 855 annotations = ["@DomName('" + key + "')"]
858 856
859 # Only add this for members, so we don't add DocsEditable to templated classes 857 # Only add this for members, so we don't add DocsEditable to templated classes
860 # (they get it from the default class template) 858 # (they get it from the default class template)
861 if member_name: 859 if member_name:
862 annotations.append('@DocsEditable'); 860 annotations.append('@DocsEditable');
863 861
864 if (dart_annotations.get(key) != None): 862 if (dart_annotations.get(key) != None):
865 annotations.extend(dart_annotations.get(key)) 863 annotations.extend(dart_annotations.get(key))
866 864
867 return annotations 865 return annotations
868 866
869 def FindDart2JSAnnotationsAndComments(idl_type, interface_name, member_name, 867 def FindDart2JSAnnotationsAndComments(idl_type, library_name, interface_name,
870 library_name=None): 868 member_name,):
871 """ Finds all annotations for Dart2JS members- including annotations for 869 """ Finds all annotations for Dart2JS members- including annotations for
872 both dart2js and dartium. 870 both dart2js and dartium.
873 """ 871 """
874 annotations = GetAnnotationsAndComments(interface_name, member_name, 872 annotations = GetAnnotationsAndComments(library_name, interface_name, member_n ame)
875 library_name)
876 873
877 ann2 = _FindDart2JSSpecificAnnotations(idl_type, interface_name, member_name) 874 ann2 = _FindDart2JSSpecificAnnotations(idl_type, interface_name, member_name)
878 if ann2: 875 if ann2:
879 if annotations: 876 if annotations:
880 annotations.extend(ann2) 877 annotations.extend(ann2)
881 else: 878 else:
882 annotations = ann2 879 annotations = ann2
883 return annotations 880 return annotations
884 881
885 def AnyConversionAnnotations(idl_type, interface_name, member_name): 882 def AnyConversionAnnotations(idl_type, interface_name, member_name):
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after
1444 self) 1441 self)
1445 1442
1446 if type_data.clazz == 'SVGTearOff': 1443 if type_data.clazz == 'SVGTearOff':
1447 dart_interface_name = self._renamer.RenameInterface( 1444 dart_interface_name = self._renamer.RenameInterface(
1448 self._database.GetInterface(type_name)) 1445 self._database.GetInterface(type_name))
1449 return SVGTearOffIDLTypeInfo( 1446 return SVGTearOffIDLTypeInfo(
1450 type_name, type_data, dart_interface_name, self) 1447 type_name, type_data, dart_interface_name, self)
1451 1448
1452 class_name = '%sIDLTypeInfo' % type_data.clazz 1449 class_name = '%sIDLTypeInfo' % type_data.clazz
1453 return globals()[class_name](type_name, type_data) 1450 return globals()[class_name](type_name, type_data)
OLDNEW
« no previous file with comments | « tools/dom/docs/docs.json ('k') | tools/dom/scripts/htmldartgenerator.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698