Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(355)

Side by Side Diff: pkg/docgen/bin/upload_docgen.py

Issue 47603014: Further fixes for including package information in docs (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Commenting out an unused failing test Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | pkg/docgen/lib/docgen.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 # 2 #
3 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 3 # Copyright (c) 2012, 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 """ This file will run docgen.dart on the SDK libraries, and upload them to 7 """ This file will run docgen.dart on the SDK libraries, and upload them to
8 Google Cloud Storage for the documentation viewer. 8 Google Cloud Storage for the documentation viewer.
9 """ 9 """
10 10
(...skipping 11 matching lines...) Expand all
22 DART = abspath(join(dirname(__file__), '../../../%s/%s/dart-sdk/bin/dart' 22 DART = abspath(join(dirname(__file__), '../../../%s/%s/dart-sdk/bin/dart'
23 % (utils.BUILD_ROOT[utils.GuessOS()], utils.GetBuildConf('release', 23 % (utils.BUILD_ROOT[utils.GuessOS()], utils.GetBuildConf('release',
24 utils.GuessArchitecture())))) 24 utils.GuessArchitecture()))))
25 PACKAGE_ROOT = abspath(join(dirname(__file__), '../../../%s/%s/packages/' 25 PACKAGE_ROOT = abspath(join(dirname(__file__), '../../../%s/%s/packages/'
26 % (utils.BUILD_ROOT[utils.GuessOS()], utils.GetBuildConf('release', 26 % (utils.BUILD_ROOT[utils.GuessOS()], utils.GetBuildConf('release',
27 utils.GuessArchitecture())))) 27 utils.GuessArchitecture()))))
28 GSUTIL = utils.GetBuildbotGSUtilPath() 28 GSUTIL = utils.GetBuildbotGSUtilPath()
29 GS_SITE = 'gs://dartlang-docgen' 29 GS_SITE = 'gs://dartlang-docgen'
30 DESCRIPTION='Runs docgen.dart on the SDK libraries, and uploads them to Google \ 30 DESCRIPTION='Runs docgen.dart on the SDK libraries, and uploads them to Google \
31 Cloud Storage for the dartdoc-viewer. ' 31 Cloud Storage for the dartdoc-viewer. '
32 32 # Allow us to override checking SVN's revision number. Useful for development
33 # so we can upload docs from a branch using an SDK that was built on a
34 # revision newer than when the branch was forked.
35 trustSVN = None
33 36
34 def GetOptions(): 37 def GetOptions():
35 parser = optparse.OptionParser(description=DESCRIPTION) 38 parser = optparse.OptionParser(description=DESCRIPTION)
36 parser.add_option('--package-root', dest='pkg_root', 39 parser.add_option('--package-root', dest='pkg_root',
37 help='The package root for dart. (Default is in the build directory.)', 40 help='The package root for dart. (Default is in the build directory.)',
38 action='store', default=PACKAGE_ROOT) 41 action='store', default=PACKAGE_ROOT)
42 parser.add_option('--dontTrustSVN', dest='dontTrustSVN', default=False,
43 help='Don''t rely on the SVN revision number, check the DART SDK instead',
44 action='store_true')
39 (options, args) = parser.parse_args() 45 (options, args) = parser.parse_args()
40 SetPackageRoot(options.pkg_root) 46 SetPackageRoot(options.pkg_root)
41 47 trustSVN = not options.dontTrustSVN
42 48
43 def SetPackageRoot(path): 49 def SetPackageRoot(path):
44 global PACKAGE_ROOT 50 global PACKAGE_ROOT
45 if exists(path): 51 if exists(path):
46 PACKAGE_ROOT = abspath(path) 52 PACKAGE_ROOT = abspath(path)
47 53
48 54
49 def SetGsutil(): 55 def SetGsutil():
50 """ If not on buildbots, find gsutil relative to docgen. """ 56 """ If not on buildbots, find gsutil relative to docgen. """
51 global GSUTIL 57 global GSUTIL
52 if not exists(GSUTIL): 58 if not exists(GSUTIL):
53 GSUTIL = abspath(join(dirname(__file__), 59 GSUTIL = abspath(join(dirname(__file__),
54 '../../../third_party/gsutil/gsutil')) 60 '../../../third_party/gsutil/gsutil'))
55 61
56 62
57 def Upload(source, target): 63 def Upload(source, target):
58 """ Upload files to Google Storage. """ 64 """ Upload files to Google Storage. """
59 cmd = [GSUTIL, '-m', 'cp', '-q', '-a', 'public-read', '-r', source, target] 65 cmd = [GSUTIL, '-m', 'cp', '-q', '-a', 'public-read', '-r', source, target]
60 (status, output) = ExecuteCommand(cmd) 66 (status, output) = ExecuteCommand(cmd)
61 return status 67 return status
62 68
63 69
64 def main(): 70 def main():
65 GetOptions() 71 GetOptions()
66 72
67 SetGsutil() 73 SetGsutil()
68 74
69 # Execute Docgen.dart on the SDK. 75 # Execute Docgen.dart on the SDK.
70 ExecuteCommand([DART, '--checked', '--package-root=' + PACKAGE_ROOT, 76 ExecuteCommand(['sh', './generate_all_docs.sh'])
71 abspath(join(dirname(__file__), 'docgen.dart')),
72 '--parse-sdk', '--json'])
73 77
74 # Use SVN Revision to get the revision number. 78 # Use SVN Revision to get the revision number.
75 revision = utils.GetSVNRevision() 79 revision = None
80 if trustSVN:
81 revision = utils.GetSVNRevision()
82
76 if revision is None: 83 if revision is None:
77 # Try to find the version from the dart-sdk folder. 84 # Try to find the version from the dart-sdk folder.
78 revision_file_location = abspath(join(dirname(__file__), 85 revision_file_location = abspath(join(dirname(__file__),
79 '../../../%s/%s/dart-sdk/revision' % (utils.BUILD_ROOT[utils.GuessOS()], 86 '../../../%s/%s/dart-sdk/revision' % (utils.BUILD_ROOT[utils.GuessOS()],
80 utils.GetBuildConf('release', utils.GuessArchitecture())))) 87 utils.GetBuildConf('release', utils.GuessArchitecture()))))
81 with open(revision_file_location, 'r') as revision_file: 88 with open(revision_file_location, 'r') as revision_file:
82 revision = revision_file.readline(5) 89 revision = revision_file.readline(5)
83 revision_file.close() 90 revision_file.close()
84 91
85 if revision is None: 92 if revision is None:
86 raise Exception("Unable to find revision. ") 93 raise Exception("Unable to find revision. ")
87 94
88 # Upload the all files in Docs into a folder based off Revision number on 95 # Upload the all files in Docs into a folder based off Revision number on
89 # Cloud Storage. 96 # Cloud Storage.
90 Upload('./docs/*', GS_SITE + '/' + revision + '/') 97 # TODO(alanknight): If we give it ./docs/* it fails to upload files in the
98 # subdirectory, probably due to escaping. Work around it by changing dir.
99 # Better, generalize this to be less dependent on the working directory.
100 os.chdir('docs')
101 Upload('.', GS_SITE + '/' + revision + '/')
102 os.chdir('..')
91 103
92 # Update VERSION file in Cloud Storage. 104 # Update VERSION file in Cloud Storage.
93 with open('VERSION', 'w') as version_file: 105 with open('VERSION', 'w') as version_file:
94 version_file.write(revision) 106 version_file.write(revision)
95 version_file.close() 107 version_file.close()
96 Upload('./VERSION', GS_SITE + '/VERSION') 108 Upload('./VERSION', GS_SITE + '/VERSION')
109 Upload('./VERSION', GS_SITE + '/' + revision + '/' + 'VERSION')
97 110
98 # Clean up the files it creates. 111 # Clean up the files it creates.
99 ExecuteCommand(['rm', '-rf', './docs']) 112 ExecuteCommand(['rm', '-rf', './docs'])
100 ExecuteCommand(['rm', '-f', './VERSION']) 113 ExecuteCommand(['rm', '-f', './VERSION'])
101 114
102 115
103 if __name__ == '__main__': 116 if __name__ == '__main__':
104 main() 117 main()
OLDNEW
« no previous file with comments | « no previous file | pkg/docgen/lib/docgen.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698