| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # | 2 # |
| 3 # Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 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 | 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. | 5 # BSD-style license that can be found in the LICENSE file. |
| 6 | 6 |
| 7 # Run this script to generate documentation for a directory and serve | 7 # Run this script to generate documentation for a directory and serve |
| 8 # the results to localhost for viewing in the browser. | 8 # the results to localhost for viewing in the browser. |
| 9 | 9 |
| 10 import optparse | 10 import optparse |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 DART_DIR = dirname(dirname(dirname(DIRECTORY))) | 21 DART_DIR = dirname(dirname(dirname(DIRECTORY))) |
| 22 DART_EXECUTABLE = join(DART_DIR, | 22 DART_EXECUTABLE = join(DART_DIR, |
| 23 '%s/%s/dart-sdk/bin/dart' % (utils.BUILD_ROOT[utils.GuessOS()], | 23 '%s/%s/dart-sdk/bin/dart' % (utils.BUILD_ROOT[utils.GuessOS()], |
| 24 utils.GetBuildConf('release', utils.GuessArchitecture()))) | 24 utils.GetBuildConf('release', utils.GuessArchitecture()))) |
| 25 PUB = join(DART_DIR, 'sdk/bin/pub') | 25 PUB = join(DART_DIR, 'sdk/bin/pub') |
| 26 DART2JS = join(DART_DIR, 'sdk/bin/dart2js') | 26 DART2JS = join(DART_DIR, 'sdk/bin/dart2js') |
| 27 PACKAGE_ROOT = join(dirname(dirname(dirname(DART_EXECUTABLE[:-(len('dart'))]))), | 27 PACKAGE_ROOT = join(dirname(dirname(dirname(DART_EXECUTABLE[:-(len('dart'))]))), |
| 28 'packages/') | 28 'packages/') |
| 29 EXCLUDED_PACKAGES = ['browser', 'html_import', 'mutation_observer', | 29 EXCLUDED_PACKAGES = ['browser', 'html_import', 'mutation_observer', |
| 30 'pkg.xcodeproj', 'shadow_dom'] | 30 'pkg.xcodeproj', 'shadow_dom'] |
| 31 APPSERVER_EXECUTABLE = 'dev_appserver.py' |
| 31 | 32 |
| 32 | 33 |
| 33 def SetPackageRoot(path): | 34 def SetPackageRoot(path): |
| 34 global PACKAGE_ROOT | 35 global PACKAGE_ROOT |
| 35 if exists(path): | 36 if exists(path): |
| 36 PACKAGE_ROOT = abspath(path) | 37 PACKAGE_ROOT = abspath(path) |
| 37 | 38 |
| 38 | 39 |
| 39 def ParseArgs(): | 40 def ParseArgs(): |
| 40 parser = optparse.OptionParser(description='Generate documentation and ' | 41 parser = optparse.OptionParser(description='Generate documentation and ' |
| 41 'display the resulting documentation in the browser.') | 42 'display the resulting documentation in the browser.') |
| 42 parser.add_option('--full-docs-only', '-d', dest='just_docs', | 43 parser.add_option('--full-docs-only', '-d', dest='just_docs', |
| 43 action='store_true', default=False, | 44 action='store_true', default=False, |
| 44 help='Only generate documentation, no html output. (If no other ' | 45 help='Only generate documentation, no html output. (If no other ' |
| 45 'options are specified, will document the SDK and all packages in the ' | 46 'options are specified, will document the SDK and all packages in the ' |
| 46 'repository.)') | 47 'repository.)') |
| 47 parser.add_option('--package-root', '-p', dest='pkg_root', | 48 parser.add_option('--package-root', '-p', dest='pkg_root', |
| 48 help='The package root for dart (default is in the build directory).', | 49 help='The package root for dart (default is in the build directory).', |
| 49 action='store', default=PACKAGE_ROOT) | 50 action='store', default=PACKAGE_ROOT) |
| 50 parser.add_option('--docgen-options', '-o', | 51 parser.add_option('--docgen-options', '-o', |
| 51 dest='docgen_options', help='Options to pass to docgen. If no file to ' | 52 dest='docgen_options', help='Options to pass to docgen. If no file to ' |
| 52 'document is specified, by default we generate all documenation for the ' | 53 'document is specified, by default we generate all documenation for the ' |
| 53 'SDK and all packages in the dart repository in JSON.', | 54 'SDK and all packages in the dart repository in JSON.', |
| 54 default='--json') | 55 default='--json') |
| 55 parser.add_option('--gae-sdk', | 56 parser.add_option('--gae-sdk', |
| 56 help='The path to the Google App Engine SDK. Defaults to the top level ' | 57 help='The path to the Google App Engine SDK. Defaults to finding the ' |
| 57 'dart directory.', default=PACKAGE_ROOT) | 58 'script in the PATH.', default='') |
| 58 options, _ = parser.parse_args() | 59 options, _ = parser.parse_args() |
| 59 SetPackageRoot(options.pkg_root) | 60 SetPackageRoot(options.pkg_root) |
| 60 return options | 61 return options |
| 61 | 62 |
| 62 | 63 |
| 63 def AddUserDocgenOptions(sdk_cmd, docgen_options, all_docs=False): | 64 def AddUserDocgenOptions(sdk_cmd, docgen_options, all_docs=False): |
| 64 '''Expand the command with user specified docgen options.''' | 65 '''Expand the command with user specified docgen options.''' |
| 65 specified_pkg = False | 66 specified_pkg = False |
| 66 remove_append = False | 67 remove_append = False |
| 67 append = '--append' | 68 append = '--append' |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 GenerateAllDocs(docgen_options) | 139 GenerateAllDocs(docgen_options) |
| 139 if not options.just_docs: | 140 if not options.just_docs: |
| 140 cwd = os.getcwd() | 141 cwd = os.getcwd() |
| 141 try: | 142 try: |
| 142 ExecuteCommand(['git', 'clone', '-b', 'master', | 143 ExecuteCommand(['git', 'clone', '-b', 'master', |
| 143 'git://github.com/dart-lang/dartdoc-viewer.git']) | 144 'git://github.com/dart-lang/dartdoc-viewer.git']) |
| 144 ExecuteCommand(['mv', 'docs', 'dartdoc-viewer/client/local']) | 145 ExecuteCommand(['mv', 'docs', 'dartdoc-viewer/client/local']) |
| 145 os.chdir('dartdoc-viewer/client/') | 146 os.chdir('dartdoc-viewer/client/') |
| 146 subprocess.call([PUB, 'install']) | 147 subprocess.call([PUB, 'install']) |
| 147 subprocess.call([DART_EXECUTABLE, 'deploy.dart']) | 148 subprocess.call([DART_EXECUTABLE, 'deploy.dart']) |
| 148 server = subprocess.Popen(['python', | 149 if options.gae_sdk == '': |
| 149 join(abspath(join(dirname(__file__), options.gae_sdk)), | 150 server = subprocess.Popen(' '.join([APPSERVER_EXECUTABLE, '..']), |
| 150 'dev_appserver.py'), '..']) | 151 shell=True) |
| 152 else: |
| 153 path_to_gae = options.gae_sdk |
| 154 if not path_to_gae.endswith(APPSERVER_EXECUTABLE): |
| 155 path_to_gae = join(path_to_gae, APPSERVER_EXECUTABLE) |
| 156 server = subprocess.Popen(join(['python', path_to_gae, '..'])) |
| 151 print ( | 157 print ( |
| 152 "\nPoint your browser to the address of the 'default' server below.") | 158 "\nPoint your browser to the address of the 'default' server below.") |
| 153 raw_input("Press <RETURN> to terminate the server.\n\n") | 159 raw_input("Press <RETURN> to terminate the server.\n\n") |
| 154 server.terminate() | 160 server.terminate() |
| 155 finally: | 161 finally: |
| 156 os.chdir(cwd) | 162 os.chdir(cwd) |
| 157 subprocess.call(['rm', '-rf', 'dartdoc-viewer']) | 163 subprocess.call(['rm', '-rf', 'dartdoc-viewer']) |
| 158 | 164 |
| 159 if __name__ == '__main__': | 165 if __name__ == '__main__': |
| 160 main() | 166 main() |
| OLD | NEW |