Chromium Code Reviews| Index: pkg/docgen/bin/dartdoc.py |
| diff --git a/pkg/docgen/bin/dartdoc.py b/pkg/docgen/bin/dartdoc.py |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..4b5ed25a41fe29ba7fd44bdb4849f1acb0ede6e4 |
| --- /dev/null |
| +++ b/pkg/docgen/bin/dartdoc.py |
| @@ -0,0 +1,75 @@ |
| +#!/usr/bin/env python |
| +# |
| +# Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| +# for details. All rights reserved. Use of this source code is governed by a |
| +# BSD-style license that can be found in the LICENSE file. |
| + |
| +""" Run this script to generate documentation for a directory and serve |
| + the results to localhost for viewing in the browser. |
| +""" |
| + |
| +import argparse |
| +import os |
| +from os.path import join, dirname, abspath, exists |
| +import platform |
| +import subprocess |
| +import sys |
| +sys.path.append(abspath(join(dirname(__file__), '../../../tools'))) |
| +import utils |
| +from upload_sdk import ExecuteCommand |
| + |
| +DART = abspath(join(dirname(__file__), '../../../%s/%s/dart-sdk/bin/dart' |
| + % (utils.BUILD_ROOT[utils.GuessOS()], utils.GetBuildConf('release', |
| + utils.GuessArchitecture())))) |
| +PUB = abspath(join(dirname(__file__), '../../../sdk/bin/pub')) |
| +DART2JS = abspath(join(dirname(__file__), '../../../sdk/bin/dart2js')) |
| +PACKAGE_ROOT = abspath(join(dirname(__file__), '../../../%s/%s/packages/' |
| + % (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.
|
| + utils.GuessArchitecture())))) |
| +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.
|
| + documentation in the browser' |
| + |
| +def SetPackageRoot(path): |
| + global PACKAGE_ROOT |
| + if exists(path): |
| + PACKAGE_ROOT = abspath(path) |
| + |
| +def GetOptions(): |
| + parser = argparse.ArgumentParser(description=DESCRIPTION) |
| + parser.add_argument('--package-root', dest='pkg_root', |
| + help='The package root for dart (default is in the build directory).', |
| + action='store', default=PACKAGE_ROOT) |
| + parser.add_argument('--options', |
| + 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
|
| + parser.add_argument('--gae-sdk', |
| + help='The path to the Google App Engine SDK.') |
| + options = parser.parse_args() |
| + SetPackageRoot(options.pkg_root) |
| + return options |
| + |
| +def main(): |
| + options = GetOptions() |
| + print(options.options.split()) |
| + docgen = [DART, '--checked', '--package-root=' + PACKAGE_ROOT, |
| + abspath(join(dirname(__file__), |
| + 'docgen.dart'))] |
| + docgen.extend(options.options.split()) |
| + ExecuteCommand(docgen) |
| + ExecuteCommand(['git', 'clone', '-b', 'dev', |
| + 'git://github.com/dart-lang/dartdoc-viewer.git']) |
| + ExecuteCommand(['mv', 'docs', 'dartdoc-viewer/client/local']) |
| + os.chdir('dartdoc-viewer/client/') |
| + subprocess.call([PUB, 'install']) |
| + subprocess.call([DART, 'build.dart']) |
| + subprocess.call([DART2JS, '-o', 'web/out/index.html_bootstrap.dart.js', |
| + './web/out/index.html_bootstrap.dart']) |
| + server = subprocess.Popen(['python', |
| + 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
|
| + '..']) |
| + raw_input("Press <RETURN> to terminate the server.\n") |
| + server.terminate() |
| + os.chdir('../..') |
| + subprocess.call(['rm', '-rf', 'dartdoc-viewer']) |
| + |
| +if __name__ == '__main__': |
| + main() |