Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: build.py

Issue 5960911785295872: Issue 2271 - Enable documentation for Chrome extensions (Closed)
Patch Set: Created April 4, 2015, 4:42 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # coding: utf-8 1 # coding: utf-8
2 2
3 # This Source Code Form is subject to the terms of the Mozilla Public 3 # This Source Code Form is subject to the terms of the Mozilla Public
4 # License, v. 2.0. If a copy of the MPL was not distributed with this 4 # License, v. 2.0. If a copy of the MPL was not distributed with this
5 # file, You can obtain one at http://mozilla.org/MPL/2.0/. 5 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 6
7 import os, sys, re, subprocess, shutil, buildtools 7 import os, sys, re, subprocess, shutil, buildtools
8 from getopt import getopt, GetoptError 8 from getopt import getopt, GetoptError
9 from StringIO import StringIO 9 from StringIO import StringIO
10 from zipfile import ZipFile 10 from zipfile import ZipFile
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 )).encode('utf-8') 362 )).encode('utf-8')
363 363
364 364
365 def generateDocs(baseDir, scriptName, opts, args, type): 365 def generateDocs(baseDir, scriptName, opts, args, type):
366 if len(args) == 0: 366 if len(args) == 0:
367 print 'No target directory specified for the documentation' 367 print 'No target directory specified for the documentation'
368 usage(scriptName, type, 'docs') 368 usage(scriptName, type, 'docs')
369 return 369 return
370 targetDir = args[0] 370 targetDir = args[0]
371 371
372 command = ['jsdoc', 372 source_dir = os.path.join(baseDir, 'lib')
373 '--destination', targetDir, 373 sources = [source_dir]
374 '--access', 'all', 374
375 os.path.join(baseDir, 'lib')] 375 # JSDoc struggles wih huge objects: https://github.com/jsdoc3/jsdoc/issues/976
kzar 2015/04/05 12:51:41 Maybe instead of this logic we could use a JSdoc c
Sebastian Noack 2015/04/05 13:08:56 This would be kinda nice, because the JSDoc config
kzar 2015/04/05 13:30:51 Wouldn't the logic be pretty simple if we use a co
Sebastian Noack 2015/04/05 13:34:33 The logic here would be reasonable. But the actual
kzar 2015/04/05 15:12:55 Fair enough I suppose.
376 if type == 'chrome':
377 sources = [os.path.join(source_dir, filename) for filename in os.listdir(sou rce_dir) if filename != 'publicSuffixList.js']
378
379 command = ['jsdoc', '--destination', targetDir, '--access', 'all'] + sources
376 if any(opt in ('-q', '--quiet') for opt, _ in opts): 380 if any(opt in ('-q', '--quiet') for opt, _ in opts):
377 process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subproces s.PIPE) 381 process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subproces s.PIPE)
378 stderr = process.communicate()[1] 382 stderr = process.communicate()[1]
379 retcode = process.poll() 383 retcode = process.poll()
380 if retcode: 384 if retcode:
381 sys.stderr.write(stderr) 385 sys.stderr.write(stderr)
382 raise subprocess.CalledProcessError(command, retcode) 386 raise subprocess.CalledProcessError(command, retcode)
383 else: 387 else:
384 subprocess.check_call(command) 388 subprocess.check_call(command)
385 389
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 command.description = 'Display description strings for all locales as specifie d in the corresponding meta.properties files.' 480 command.description = 'Display description strings for all locales as specifie d in the corresponding meta.properties files.'
477 command.addOption('Only include the given locales', short='l', long='locales', value='l1,l2,l3') 481 command.addOption('Only include the given locales', short='l', long='locales', value='l1,l2,l3')
478 command.params = '[options]' 482 command.params = '[options]'
479 command.supportedTypes = ('gecko') 483 command.supportedTypes = ('gecko')
480 484
481 with addCommand(generateDocs, 'docs') as command: 485 with addCommand(generateDocs, 'docs') as command:
482 command.shortDescription = 'Generate documentation (requires node.js)' 486 command.shortDescription = 'Generate documentation (requires node.js)'
483 command.description = 'Generate documentation files and write them into the sp ecified directory. This operation requires JsDoc 3 to be installed.' 487 command.description = 'Generate documentation files and write them into the sp ecified directory. This operation requires JsDoc 3 to be installed.'
484 command.addOption('Suppress JsDoc output', short='q', long='quiet') 488 command.addOption('Suppress JsDoc output', short='q', long='quiet')
485 command.params = '[options] <directory>' 489 command.params = '[options] <directory>'
486 command.supportedTypes = ('gecko') 490 command.supportedTypes = ('gecko', 'chrome')
487 491
488 with addCommand(runReleaseAutomation, 'release') as command: 492 with addCommand(runReleaseAutomation, 'release') as command:
489 command.shortDescription = 'Run release automation' 493 command.shortDescription = 'Run release automation'
490 command.description = 'Note: If you are not the project owner then you '\ 494 command.description = 'Note: If you are not the project owner then you '\
491 'probably don\'t want to run this!\n\n'\ 495 'probably don\'t want to run this!\n\n'\
492 'Runs release automation: creates downloads for the new version, tags '\ 496 'Runs release automation: creates downloads for the new version, tags '\
493 'source code repository as well as downloads and buildtools repository.' 497 'source code repository as well as downloads and buildtools repository.'
494 command.addOption('File containing private key and certificates required to si gn the release. Note that for Chrome releases this option needs to be specified twice: first a key to sign Chrome/Opera builds, then another to sign the Safari build.', short='k', long='key', value='file', types=('gecko', 'chrome')) 498 command.addOption('File containing private key and certificates required to si gn the release. Note that for Chrome releases this option needs to be specified twice: first a key to sign Chrome/Opera builds, then another to sign the Safari build.', short='k', long='key', value='file', types=('gecko', 'chrome'))
495 command.addOption('Directory containing downloads repository (if omitted ../do wnloads is assumed)', short='d', long='downloads', value='dir') 499 command.addOption('Directory containing downloads repository (if omitted ../do wnloads is assumed)', short='d', long='downloads', value='dir')
496 command.params = '[options] <version>' 500 command.params = '[options] <version>'
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
565 if option in ('-h', '--help'): 569 if option in ('-h', '--help'):
566 usage(scriptName, type, command) 570 usage(scriptName, type, command)
567 sys.exit() 571 sys.exit()
568 commands[command](baseDir, scriptName, opts, args, type) 572 commands[command](baseDir, scriptName, opts, args, type)
569 else: 573 else:
570 print 'Command %s is not supported for this application type' % command 574 print 'Command %s is not supported for this application type' % command
571 usage(scriptName, type) 575 usage(scriptName, type)
572 else: 576 else:
573 print 'Command %s is unrecognized' % command 577 print 'Command %s is unrecognized' % command
574 usage(scriptName, type) 578 usage(scriptName, type)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld