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

Side by Side Diff: build.py

Issue 29531680: Issue 5560 - Specify the JSDoc dependency explicitly (Closed)
Patch Set: Created Aug. 30, 2017, 3:24 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 | package.json » ('j') | package-lock.json » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # This Source Code Form is subject to the terms of the Mozilla Public 1 # This Source Code Form is subject to the terms of the Mozilla Public
2 # License, v. 2.0. If a copy of the MPL was not distributed with this 2 # License, v. 2.0. If a copy of the MPL was not distributed with this
3 # file, You can obtain one at http://mozilla.org/MPL/2.0/. 3 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
4 4
5 import os 5 import os
6 import sys 6 import sys
7 import re 7 import re
8 import subprocess 8 import subprocess
9 import shutil 9 import shutil
10 import buildtools 10 import buildtools
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 return 404 return
405 targetDir = args[0] 405 targetDir = args[0]
406 406
407 source_dir = os.path.join(baseDir, 'lib') 407 source_dir = os.path.join(baseDir, 'lib')
408 sources = [source_dir] 408 sources = [source_dir]
409 409
410 # JSDoc struggles wih huge objects: https://github.com/jsdoc3/jsdoc/issues/9 76 410 # JSDoc struggles wih huge objects: https://github.com/jsdoc3/jsdoc/issues/9 76
411 if type == 'chrome': 411 if type == 'chrome':
412 sources = [os.path.join(source_dir, filename) for filename in os.listdir (source_dir) if filename != 'publicSuffixList.js'] 412 sources = [os.path.join(source_dir, filename) for filename in os.listdir (source_dir) if filename != 'publicSuffixList.js']
413 413
414 config = os.path.join(os.path.dirname(__file__), 'jsdoc.conf') 414 buildtools_path = os.path.dirname(__file__)
415 command = ['jsdoc', '--destination', targetDir, '--configure', config] + sou rces 415 config = os.path.join(buildtools_path, 'jsdoc.conf')
416
417 command = ['npm', 'run-script', 'jsdoc', '--', '--destination', targetDir,
418 '--configure', config] + sources
416 if any(opt in ('-q', '--quiet') for opt, _ in opts): 419 if any(opt in ('-q', '--quiet') for opt, _ in opts):
417 process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subpr ocess.PIPE) 420 process = subprocess.Popen(command, stdout=subprocess.PIPE,
421 stderr=subprocess.PIPE, cwd=buildtools_path)
418 stderr = process.communicate()[1] 422 stderr = process.communicate()[1]
419 retcode = process.poll() 423 retcode = process.poll()
420 if retcode: 424 if retcode:
421 sys.stderr.write(stderr) 425 sys.stderr.write(stderr)
422 raise subprocess.CalledProcessError(command, retcode) 426 raise subprocess.CalledProcessError(command, retcode)
423 else: 427 else:
424 subprocess.check_call(command) 428 subprocess.check_call(command, cwd=buildtools_path)
425 429
426 430
427 def runReleaseAutomation(baseDir, scriptName, opts, args, type): 431 def runReleaseAutomation(baseDir, scriptName, opts, args, type):
428 keyFile = None 432 keyFile = None
429 downloadsRepo = os.path.join(baseDir, '..', 'downloads') 433 downloadsRepo = os.path.join(baseDir, '..', 'downloads')
430 for option, value in opts: 434 for option, value in opts:
431 if option in ('-k', '--key'): 435 if option in ('-k', '--key'):
432 keyFile = value 436 keyFile = value
433 elif option in ('-d', '--downloads'): 437 elif option in ('-d', '--downloads'):
434 downloadsRepo = value 438 downloadsRepo = value
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 512
509 with addCommand(showDescriptions, 'showdesc') as command: 513 with addCommand(showDescriptions, 'showdesc') as command:
510 command.shortDescription = 'Print description strings for all locales' 514 command.shortDescription = 'Print description strings for all locales'
511 command.description = 'Display description strings for all locales as specif ied in the corresponding meta.properties files.' 515 command.description = 'Display description strings for all locales as specif ied in the corresponding meta.properties files.'
512 command.addOption('Only include the given locales', short='l', long='locales ', value='l1,l2,l3') 516 command.addOption('Only include the given locales', short='l', long='locales ', value='l1,l2,l3')
513 command.params = '[options]' 517 command.params = '[options]'
514 command.supportedTypes = ('gecko') 518 command.supportedTypes = ('gecko')
515 519
516 with addCommand(generateDocs, 'docs') as command: 520 with addCommand(generateDocs, 'docs') as command:
517 command.shortDescription = 'Generate documentation (requires node.js)' 521 command.shortDescription = 'Generate documentation (requires node.js)'
518 command.description = 'Generate documentation files and write them into the specified directory. This operation requires JsDoc 3 to be installed.' 522 command.description = 'Generate documentation files and write them into the specified directory.'
tlucas 2017/08/30 17:33:21 nit: While at it, how do you feel about limiting l
kzar 2017/08/31 10:54:35 Done.
519 command.addOption('Suppress JsDoc output', short='q', long='quiet') 523 command.addOption('Suppress JsDoc output', short='q', long='quiet')
520 command.params = '[options] <directory>' 524 command.params = '[options] <directory>'
521 command.supportedTypes = ('gecko', 'chrome') 525 command.supportedTypes = ('gecko', 'chrome')
522 526
523 with addCommand(runReleaseAutomation, 'release') as command: 527 with addCommand(runReleaseAutomation, 'release') as command:
524 command.shortDescription = 'Run release automation' 528 command.shortDescription = 'Run release automation'
525 command.description = 'Note: If you are not the project owner then you ' "probably don't want to run this!\n\n" 'Runs release automation: crea tes downloads for the new version, tags ' 'source code repository as well as downloads and buildtools repository.' 529 command.description = 'Note: If you are not the project owner then you ' "probably don't want to run this!\n\n" 'Runs release automation: crea tes downloads for the new version, tags ' 'source code repository as well as downloads and buildtools repository.'
526 command.addOption('File containing private key and certificates required to sign the release.', short='k', long='key', value='file', types=('chrome', 'safar i', 'edge')) 530 command.addOption('File containing private key and certificates required to sign the release.', short='k', long='key', value='file', types=('chrome', 'safar i', 'edge'))
527 command.addOption('Directory containing downloads repository (if omitted ../ downloads is assumed)', short='d', long='downloads', value='dir') 531 command.addOption('Directory containing downloads repository (if omitted ../ downloads is assumed)', short='d', long='downloads', value='dir')
528 command.params = '[options] <version>' 532 command.params = '[options] <version>'
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 if option in ('-h', '--help'): 603 if option in ('-h', '--help'):
600 usage(scriptName, type, command) 604 usage(scriptName, type, command)
601 sys.exit() 605 sys.exit()
602 commands[command](baseDir, scriptName, opts, args, type) 606 commands[command](baseDir, scriptName, opts, args, type)
603 else: 607 else:
604 print 'Command %s is not supported for this application type' % comm and 608 print 'Command %s is not supported for this application type' % comm and
605 usage(scriptName, type) 609 usage(scriptName, type)
606 else: 610 else:
607 print 'Command %s is unrecognized' % command 611 print 'Command %s is unrecognized' % command
608 usage(scriptName, type) 612 usage(scriptName, type)
OLDNEW
« no previous file with comments | « no previous file | package.json » ('j') | package-lock.json » ('J')

Powered by Google App Engine
This is Rietveld