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

Side by Side Diff: sdk/lib/html/scripts/dartdomgenerator.py

Issue 11412144: HTML human writable docs working end to end!... mostly... (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: All of Bob's code review changes.' Created 8 years 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) 2011, the Dart project authors. Please see the AUTHORS file 2 # Copyright (c) 2011, 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 is the entry point to create Dart APIs from the IDL database.""" 6 """This is the entry point to create Dart APIs from the IDL database."""
7 7
8 import dartgenerator 8 import dartgenerator
9 import database 9 import database
10 import fremontcutbuilder 10 import fremontcutbuilder
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 emitters, dart_output_dir, dart_libraries) 78 emitters, dart_output_dir, dart_libraries)
79 event_generator = HtmlEventGenerator(webkit_database, template_loader) 79 event_generator = HtmlEventGenerator(webkit_database, template_loader)
80 80
81 def generate_interface(interface): 81 def generate_interface(interface):
82 backend = backend_factory(interface) 82 backend = backend_factory(interface)
83 interface_generator = HtmlDartInterfaceGenerator( 83 interface_generator = HtmlDartInterfaceGenerator(
84 options, dart_library_emitter, event_generator, interface, backend) 84 options, dart_library_emitter, event_generator, interface, backend)
85 interface_generator.Generate() 85 interface_generator.Generate()
86 86
87 generator.Generate(webkit_database, common_database, generate_interface) 87 generator.Generate(webkit_database, common_database, generate_interface)
88
88 dart_library_emitter.EmitLibraries(auxiliary_dir) 89 dart_library_emitter.EmitLibraries(auxiliary_dir)
89 90
90 if dart2js_output_dir: 91 if dart2js_output_dir:
91 template_paths = ['html/dart2js', 'html/impl', 'html/interface', ''] 92 template_paths = ['html/dart2js', 'html/impl', 'html/interface', '']
92 template_loader = TemplateLoader(template_dir, 93 template_loader = TemplateLoader(template_dir,
93 template_paths, 94 template_paths,
94 {'DARTIUM': False, 'DART2JS': True}) 95 {'DARTIUM': False, 'DART2JS': True})
95 backend_options = GeneratorOptions( 96 backend_options = GeneratorOptions(
96 template_loader, webkit_database, type_registry, renamer) 97 template_loader, webkit_database, type_registry, renamer)
97 backend_factory = lambda interface:\ 98 backend_factory = lambda interface:\
(...skipping 26 matching lines...) Expand all
124 template_loader, backend_factory) 125 template_loader, backend_factory)
125 cpp_library_emitter.EmitDerivedSources( 126 cpp_library_emitter.EmitDerivedSources(
126 template_loader.Load('cpp_derived_sources.template'), 127 template_loader.Load('cpp_derived_sources.template'),
127 dartium_output_dir) 128 dartium_output_dir)
128 cpp_library_emitter.EmitResolver( 129 cpp_library_emitter.EmitResolver(
129 template_loader.Load('cpp_resolver.template'), dartium_output_dir) 130 template_loader.Load('cpp_resolver.template'), dartium_output_dir)
130 131
131 _logger.info('Flush...') 132 _logger.info('Flush...')
132 emitters.Flush() 133 emitters.Flush()
133 134
134 def GenerateSingleFile(library_path, output_dir): 135 def GenerateSingleFile(library_path, output_dir, generated_output_dir=None):
135 library_dir = os.path.dirname(library_path) 136 library_dir = os.path.dirname(library_path)
136 library_filename = os.path.basename(library_path) 137 library_filename = os.path.basename(library_path)
137 copy_dart_script = os.path.relpath('../../../../tools/copy_dart.py', 138 copy_dart_script = os.path.relpath('../../../../tools/copy_dart.py',
138 library_dir) 139 library_dir)
139 output_dir = os.path.relpath(output_dir, library_dir) 140 output_dir = os.path.relpath(output_dir, library_dir)
140 command = ' '.join(['cd', library_dir, ';', 141 command = ' '.join(['cd', library_dir, ';',
141 copy_dart_script, output_dir, library_filename]) 142 copy_dart_script, output_dir, library_filename])
142 subprocess.call([command], shell=True) 143 subprocess.call([command], shell=True)
143 144
144 def main(): 145 def main():
(...skipping 18 matching lines...) Expand all
163 help='''Use the cached database from the previous run to 164 help='''Use the cached database from the previous run to
164 improve startup performance''') 165 improve startup performance''')
165 (options, args) = parser.parse_args() 166 (options, args) = parser.parse_args()
166 167
167 current_dir = os.path.dirname(__file__) 168 current_dir = os.path.dirname(__file__)
168 database_dir = os.path.join(current_dir, '..', 'database') 169 database_dir = os.path.join(current_dir, '..', 'database')
169 logging.config.fileConfig(os.path.join(current_dir, 'logging.conf')) 170 logging.config.fileConfig(os.path.join(current_dir, 'logging.conf'))
170 systems = options.systems.split(',') 171 systems = options.systems.split(',')
171 172
172 output_dir = options.output_dir or os.path.join(current_dir, '../generated') 173 output_dir = options.output_dir or os.path.join(current_dir, '../generated')
174
173 dart2js_output_dir = None 175 dart2js_output_dir = None
174 if 'htmldart2js' in systems: 176 if 'htmldart2js' in systems:
175 dart2js_output_dir = os.path.join(output_dir, 'dart2js') 177 dart2js_output_dir = os.path.join(output_dir, 'dart2js')
176 dartium_output_dir = None 178 dartium_output_dir = None
177 if 'htmldartium' in systems: 179 if 'htmldartium' in systems:
178 dartium_output_dir = os.path.join(output_dir, 'dartium') 180 dartium_output_dir = os.path.join(output_dir, 'dartium')
179 181
180 if options.rebuild: 182 if options.rebuild:
181 # Parse the IDL and create the database. 183 # Parse the IDL and create the database.
182 database = fremontcutbuilder.main(options.parallel) 184 database = fremontcutbuilder.main(options.parallel)
183 else: 185 else:
184 # Load the previously generated database. 186 # Load the previously generated database.
185 database = LoadDatabase(database_dir, options.use_database_cache) 187 database = LoadDatabase(database_dir, options.use_database_cache)
186 GenerateFromDatabase(database, dart2js_output_dir, dartium_output_dir) 188 GenerateFromDatabase(database, dart2js_output_dir, dartium_output_dir)
187 189
190 _logger.info('Add documentation to generated classes.')
191 html_to_json_script = os.path.relpath(
192 '../../../../tools/html_json_doc/bin/html_json_doc.dart',
193 current_dir)
194 html_output_dir = os.path.join(output_dir, 'dart2js/dart/html/')
195 svg_output_dir = os.path.join(output_dir, 'dart2js/dart/svg/')
196 html_json_path = os.path.relpath('../docs/html_docs.json')
197 svg_json_path = os.path.relpath('../docs/svg_docs.json')
198 html_command = ' '.join(['dart', html_to_json_script, '--mode=json-to-html',
199 html_output_dir, html_json_path])
200 svg_command = ' '.join(['dart', html_to_json_script, '--mode=json-to-html',
201 svg_output_dir, svg_json_path])
202 subprocess.call([html_command], shell=True)
203 subprocess.call([svg_command], shell=True)
204
188 if 'htmldart2js' in systems: 205 if 'htmldart2js' in systems:
189 _logger.info('Generating dart2js single files.') 206 _logger.info('Generating dart2js single files.')
190 GenerateSingleFile(os.path.join(dart2js_output_dir, 'html_dart2js.dart'), 207 GenerateSingleFile(os.path.join(dart2js_output_dir, 'html_dart2js.dart'),
191 '../dart2js') 208 '../dart2js')
192 GenerateSingleFile(os.path.join(dart2js_output_dir, 'svg_dart2js.dart'), 209 GenerateSingleFile(os.path.join(dart2js_output_dir, 'svg_dart2js.dart'),
193 '../../svg/dart2js') 210 '../../svg/dart2js')
194 if 'htmldartium' in systems: 211 if 'htmldartium' in systems:
195 _logger.info('Generating dartium single files.') 212 _logger.info('Generating dartium single files.')
196 GenerateSingleFile(os.path.join(dartium_output_dir, 'html_dartium.dart'), 213 GenerateSingleFile(os.path.join(dartium_output_dir, 'html_dartium.dart'),
197 '../dartium') 214 '../dartium')
198 GenerateSingleFile(os.path.join(dartium_output_dir, 'svg_dartium.dart'), 215 GenerateSingleFile(os.path.join(dartium_output_dir, 'svg_dartium.dart'),
199 '../../svg/dartium') 216 '../../svg/dartium')
200 217
201 if __name__ == '__main__': 218 if __name__ == '__main__':
202 sys.exit(main()) 219 sys.exit(main())
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698