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..a3fadb6bf9b2b7484307b7276cd8c48957829298 |
| --- /dev/null |
| +++ b/pkg/docgen/bin/dartdoc.py |
| @@ -0,0 +1,77 @@ |
| +#!/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 |
| + |
| +DIRECTORY = abspath(dirname(__file__)) |
| +DART = join(DIRECTORY, '../../../%s/%s/dart-sdk/bin/dart' |
| + % (utils.BUILD_ROOT[utils.GuessOS()], utils.GetBuildConf('release', |
| + utils.GuessArchitecture()))) |
| +PUB = join(DIRECTORY, '../../../sdk/bin/pub') |
| +DART2JS = join(DIRECTORY, '../../../sdk/bin/dart2js') |
| +PACKAGE_ROOT = join(DART[:-(len('dart'))], '../../packages/') |
| + |
| +def SetPackageRoot(path): |
| + global PACKAGE_ROOT |
| + if exists(path): |
| + PACKAGE_ROOT = abspath(path) |
| + |
| +def GetOptions(): |
| + summary = 'Runs docgen on the specified library and displays the \ |
|
Emily Fortuna
2013/08/12 21:05:05
how about isntead of the backslash write:
summar
|
| + resulting documentation in the browser' |
| + parser = argparse.ArgumentParser(description=summary) |
| + 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) |
| + docgen = [DART, '--checked', '--package-root=' + PACKAGE_ROOT, |
| + join(DIRECTORY, 'docgen.dart'), '-h'] |
|
Emily Fortuna
2013/08/12 21:05:05
if this is messy, I'd say take it out. Use your be
|
| + process = subprocess.Popen(docgen, stdout=subprocess.PIPE) |
| + out, error = process.communicate() |
|
Emily Fortuna
2013/08/12 21:05:05
indentation
|
| + parser.add_argument('--options', |
| + help=out) |
| + 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() |
| + docgen = [DART, '--checked', '--package-root=' + PACKAGE_ROOT, |
| + join(DIRECTORY, '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'), |
| + '..']) |
| + print("\nPoint your browser to the address of the 'default' server below.") |
| + raw_input("Press <RETURN> to terminate the server.\n\n") |
| + server.terminate() |
| + os.chdir('../..') |
| + subprocess.call(['rm', '-rf', 'dartdoc-viewer']) |
| + |
| +if __name__ == '__main__': |
| + main() |