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: Addressed nit Created Aug. 31, 2017, 10:51 a.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') | no next file with comments »
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 ' \
523 'the specified directory.'
tlucas 2017/08/31 12:20:58 Sorry for bothering, PEP 8 prefers implicit contin
kzar 2017/08/31 12:24:54 Done.
519 command.addOption('Suppress JsDoc output', short='q', long='quiet') 524 command.addOption('Suppress JsDoc output', short='q', long='quiet')
520 command.params = '[options] <directory>' 525 command.params = '[options] <directory>'
521 command.supportedTypes = ('gecko', 'chrome') 526 command.supportedTypes = ('gecko', 'chrome')
522 527
523 with addCommand(runReleaseAutomation, 'release') as command: 528 with addCommand(runReleaseAutomation, 'release') as command:
524 command.shortDescription = 'Run release automation' 529 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.' 530 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')) 531 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') 532 command.addOption('Directory containing downloads repository (if omitted ../ downloads is assumed)', short='d', long='downloads', value='dir')
528 command.params = '[options] <version>' 533 command.params = '[options] <version>'
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 if option in ('-h', '--help'): 604 if option in ('-h', '--help'):
600 usage(scriptName, type, command) 605 usage(scriptName, type, command)
601 sys.exit() 606 sys.exit()
602 commands[command](baseDir, scriptName, opts, args, type) 607 commands[command](baseDir, scriptName, opts, args, type)
603 else: 608 else:
604 print 'Command %s is not supported for this application type' % comm and 609 print 'Command %s is not supported for this application type' % comm and
605 usage(scriptName, type) 610 usage(scriptName, type)
606 else: 611 else:
607 print 'Command %s is unrecognized' % command 612 print 'Command %s is unrecognized' % command
608 usage(scriptName, type) 613 usage(scriptName, type)
OLDNEW
« no previous file with comments | « no previous file | package.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld