Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 #!/usr/bin/env python | |
| 2 # | |
| 3 # Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | |
| 4 # for details. All rights reserved. Use of this source code is governed by a | |
| 5 # BSD-style license that can be found in the LICENSE file. | |
| 6 | |
| 7 """ Run this script to generate documentation for a directory and serve | |
| 8 the results to localhost for viewing in the browser. | |
| 9 """ | |
| 10 | |
| 11 import argparse | |
| 12 import os | |
| 13 from os.path import join, dirname, abspath, exists | |
| 14 import platform | |
| 15 import subprocess | |
| 16 import sys | |
| 17 sys.path.append(abspath(join(dirname(__file__), '../../../tools'))) | |
| 18 import utils | |
| 19 from upload_sdk import ExecuteCommand | |
| 20 | |
| 21 DART = abspath(join(dirname(__file__), '../../../%s/%s/dart-sdk/bin/dart' | |
| 22 % (utils.BUILD_ROOT[utils.GuessOS()], utils.GetBuildConf('release', | |
| 23 utils.GuessArchitecture())))) | |
| 24 PUB = abspath(join(dirname(__file__), '../../../sdk/bin/pub')) | |
| 25 DART2JS = abspath(join(dirname(__file__), '../../../sdk/bin/dart2js')) | |
| 26 PACKAGE_ROOT = abspath(join(dirname(__file__), '../../../%s/%s/packages/' | |
| 27 % (utils.BUILD_ROOT[utils.GuessOS()], utils.GetBuildConf('release', | |
|
Emily Fortuna
2013/08/12 17:04:05
just a suggestion -- consider creating the package
Tate Mandel
2013/08/12 20:24:04
Done.
| |
| 28 utils.GuessArchitecture())))) | |
| 29 DESCRIPTION='Runs docgen on the specified library and displays the resulting \ | |
|
Emily Fortuna
2013/08/12 17:04:05
does this need to be a global? It's just used in o
Tate Mandel
2013/08/12 20:24:04
Done.
| |
| 30 documentation in the browser' | |
| 31 | |
| 32 def SetPackageRoot(path): | |
| 33 global PACKAGE_ROOT | |
| 34 if exists(path): | |
| 35 PACKAGE_ROOT = abspath(path) | |
| 36 | |
| 37 def GetOptions(): | |
| 38 parser = argparse.ArgumentParser(description=DESCRIPTION) | |
| 39 parser.add_argument('--package-root', dest='pkg_root', | |
| 40 help='The package root for dart (default is in the build directory).', | |
| 41 action='store', default=PACKAGE_ROOT) | |
| 42 parser.add_argument('--options', | |
| 43 help='The options being passed into docgen.') | |
|
Emily Fortuna
2013/08/12 17:04:05
would it be possible to invoke dogen.dart --help,
Tate Mandel
2013/08/12 20:24:04
Done. - argparse doesn't allow the help text to ha
Emily Fortuna
2013/08/12 21:05:05
Oh, hm... well if it's unreadable don't bother. I
| |
| 44 parser.add_argument('--gae-sdk', | |
| 45 help='The path to the Google App Engine SDK.') | |
| 46 options = parser.parse_args() | |
| 47 SetPackageRoot(options.pkg_root) | |
| 48 return options | |
| 49 | |
| 50 def main(): | |
| 51 options = GetOptions() | |
| 52 print(options.options.split()) | |
| 53 docgen = [DART, '--checked', '--package-root=' + PACKAGE_ROOT, | |
| 54 abspath(join(dirname(__file__), | |
| 55 'docgen.dart'))] | |
| 56 docgen.extend(options.options.split()) | |
| 57 ExecuteCommand(docgen) | |
| 58 ExecuteCommand(['git', 'clone', '-b', 'dev', | |
| 59 'git://github.com/dart-lang/dartdoc-viewer.git']) | |
| 60 ExecuteCommand(['mv', 'docs', 'dartdoc-viewer/client/local']) | |
| 61 os.chdir('dartdoc-viewer/client/') | |
| 62 subprocess.call([PUB, 'install']) | |
| 63 subprocess.call([DART, 'build.dart']) | |
| 64 subprocess.call([DART2JS, '-o', 'web/out/index.html_bootstrap.dart.js', | |
| 65 './web/out/index.html_bootstrap.dart']) | |
| 66 server = subprocess.Popen(['python', | |
| 67 join(abspath(join(dirname(__file__), options.gae_sdk)), 'dev_appserver.py'), | |
|
Emily Fortuna
2013/08/12 17:04:05
Could you print a line here saying "now point your
Tate Mandel
2013/08/12 20:24:04
The dev server prints a few lines when it starts s
| |
| 68 '..']) | |
| 69 raw_input("Press <RETURN> to terminate the server.\n") | |
| 70 server.terminate() | |
| 71 os.chdir('../..') | |
| 72 subprocess.call(['rm', '-rf', 'dartdoc-viewer']) | |
| 73 | |
| 74 if __name__ == '__main__': | |
| 75 main() | |
| OLD | NEW |