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

Side by Side Diff: chrome/common/extensions/docs/build/build.py

Issue 10082038: Hack together a quick doc generator for IDL files. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: separate alarms change Created 8 years, 8 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 | « no previous file | chrome/common/extensions/docs/build/directory.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 Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Docbuilder for extension docs.""" 6 """Docbuilder for extension docs."""
7 7
8 import glob 8 import glob
9 import os 9 import os
10 import os.path 10 import os.path
11 import shutil 11 import shutil
12 import sys 12 import sys
13 import time 13 import time
14 import urllib 14 import urllib
15 15
16 from subprocess import Popen, PIPE 16 from subprocess import Popen, PIPE
17 from optparse import OptionParser 17 from optparse import OptionParser
18 18
19 _script_path = os.path.realpath(__file__) 19 _script_path = os.path.realpath(__file__)
20 _build_dir = os.path.dirname(_script_path) 20 _build_dir = os.path.dirname(_script_path)
21 _base_dir = os.path.normpath(_build_dir + "/..") 21 _base_dir = os.path.normpath(_build_dir + "/..")
22 _static_dir = _base_dir + "/static" 22 _static_dir = _base_dir + "/static"
23 _js_dir = _base_dir + "/js" 23 _js_dir = _base_dir + "/js"
24 _template_dir = _base_dir + "/template" 24 _template_dir = _base_dir + "/template"
25 _samples_dir = _base_dir + "/examples" 25 _samples_dir = _base_dir + "/examples"
26 _extension_api_dir = os.path.normpath(_base_dir + "/../api") 26 _extension_api_dir = os.path.normpath(_base_dir + "/../api")
27 27
28 _extension_api_json_schemas = glob.glob(_extension_api_dir + 28 _extension_api_json_schemas = glob.glob(_extension_api_dir +
29 '/[a-zA-Z0-9]*.json') 29 '/[a-zA-Z0-9]*.json')
30 _extension_api_idl_schemas = glob.glob(_extension_api_dir +
31 '/[a-zA-Z0-9]*.idl')
30 _api_template_html = _template_dir + "/api_template.html" 32 _api_template_html = _template_dir + "/api_template.html"
31 _page_shell_html = _template_dir + "/page_shell.html" 33 _page_shell_html = _template_dir + "/page_shell.html"
32 _generator_html = _build_dir + "/generator.html" 34 _generator_html = _build_dir + "/generator.html"
33 _samples_json = _base_dir + "/samples.json" 35 _samples_json = _base_dir + "/samples.json"
34 36
35 _expected_output_preamble = "#BEGIN" 37 _expected_output_preamble = "#BEGIN"
36 _expected_output_postamble = "#END" 38 _expected_output_postamble = "#END"
37 39
38 # HACK! This is required because we can only depend on python 2.4 and 40 # HACK! This is required because we can only depend on python 2.4 and
39 # the calling environment may not be setup to set the PYTHONPATH 41 # the calling environment may not be setup to set the PYTHONPATH
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 default=True) 188 default=True)
187 options, args = parser.parse_args() 189 options, args = parser.parse_args()
188 190
189 if (options.dump_render_tree_path and 191 if (options.dump_render_tree_path and
190 os.path.isfile(options.dump_render_tree_path)): 192 os.path.isfile(options.dump_render_tree_path)):
191 dump_render_tree = options.dump_render_tree_path 193 dump_render_tree = options.dump_render_tree_path
192 else: 194 else:
193 dump_render_tree = FindDumpRenderTree() 195 dump_render_tree = FindDumpRenderTree()
194 196
195 # Load the manifest of existing API Methods 197 # Load the manifest of existing API Methods
196 api_manifest = ApiManifest(_extension_api_json_schemas) 198 api_manifest = ApiManifest(_extension_api_json_schemas,
199 _extension_api_idl_schemas)
197 200
198 # Read static file names 201 # Read static file names
199 static_names = GetStaticFileNames() 202 static_names = GetStaticFileNames()
200 203
201 # Read module names 204 # Read module names
202 module_names = api_manifest.getModuleNames() 205 module_names = api_manifest.getModuleNames()
203 206
204 # All pages to generate 207 # All pages to generate
205 page_names = static_names | module_names 208 page_names = static_names | module_names
206 209
207 # Allow the user to render a single page if they want 210 # Allow the user to render a single page if they want
208 if options.page_name: 211 if options.page_name:
209 if options.page_name in page_names: 212 if options.page_name in page_names:
210 page_names = [options.page_name] 213 page_names = [options.page_name]
211 else: 214 else:
212 raise Exception("--page-name argument must be one of %s." % 215 raise Exception("--page-name argument must be one of %s." %
213 ', '.join(sorted(page_names))) 216 ', '.join(sorted(page_names)))
214 217
218 # Write temporary JSON files based on the IDL inputs
219 api_manifest.generateJSONFromIDL()
220
215 # Render a manifest file containing metadata about all the extension samples 221 # Render a manifest file containing metadata about all the extension samples
216 samples_manifest = SamplesManifest(_samples_dir, _base_dir, api_manifest) 222 samples_manifest = SamplesManifest(_samples_dir, _base_dir, api_manifest)
217 samples_manifest.writeToFile(_samples_json) 223 samples_manifest.writeToFile(_samples_json)
218 224
219 # Write zipped versions of the samples listed in the manifest to the 225 # Write zipped versions of the samples listed in the manifest to the
220 # filesystem, unless the user has disabled it 226 # filesystem, unless the user has disabled it
221 if options.zips: 227 if options.zips:
222 modified_zips = samples_manifest.writeZippedSamples() 228 modified_zips = samples_manifest.writeZippedSamples()
223 else: 229 else:
224 modified_zips = [] 230 modified_zips = []
(...skipping 11 matching lines...) Expand all
236 for f in modified_files: 242 for f in modified_files:
237 print " * %s" % f 243 print " * %s" % f
238 244
239 # Hack. Sleep here, otherwise windows doesn't properly close the debug.log 245 # Hack. Sleep here, otherwise windows doesn't properly close the debug.log
240 # and the os.remove will fail with a "Permission denied". 246 # and the os.remove will fail with a "Permission denied".
241 time.sleep(1) 247 time.sleep(1)
242 debug_log = os.path.normpath(_build_dir + "/" + "debug.log") 248 debug_log = os.path.normpath(_build_dir + "/" + "debug.log")
243 if (os.path.isfile(debug_log)): 249 if (os.path.isfile(debug_log)):
244 os.remove(debug_log) 250 os.remove(debug_log)
245 251
252 # Cleanup our temporary IDL->JSON files
253 api_manifest.cleanupGeneratedFiles()
254
246 if 'EX_OK' in dir(os): 255 if 'EX_OK' in dir(os):
247 return os.EX_OK 256 return os.EX_OK
248 else: 257 else:
249 return 0 258 return 0
250 259
251 if __name__ == '__main__': 260 if __name__ == '__main__':
252 sys.exit(main()) 261 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | chrome/common/extensions/docs/build/directory.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698