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

Side by Side Diff: utils/apidoc/apidoc.dart

Issue 14736010: Add a new --extra-lib option to apidoc that allows us to specify an explicit .dart file that should… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 7 months 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 | « pkg/unittest/lib/unittest.dart ('k') | utils/apidoc/apidoc.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /** 5 /**
6 * This generates the reference documentation for the core libraries that come 6 * This generates the reference documentation for the core libraries that come
7 * with dart. It is built on top of dartdoc, which is a general-purpose library 7 * with dart. It is built on top of dartdoc, which is a general-purpose library
8 * for generating docs from any Dart code. This library extends that to include 8 * for generating docs from any Dart code. This library extends that to include
9 * additional information and styling specific to our standard library. 9 * additional information and styling specific to our standard library.
10 * 10 *
(...skipping 21 matching lines...) Expand all
32 HtmlDiff _diff; 32 HtmlDiff _diff;
33 33
34 void main() { 34 void main() {
35 final args = new Options().arguments; 35 final args = new Options().arguments;
36 36
37 int mode = MODE_STATIC; 37 int mode = MODE_STATIC;
38 Path outputDir = new Path('docs'); 38 Path outputDir = new Path('docs');
39 bool generateAppCache = false; 39 bool generateAppCache = false;
40 40
41 List<String> excludedLibraries = <String>[]; 41 List<String> excludedLibraries = <String>[];
42
43 // For libraries that have names matching the package name,
44 // such as library unittest in package unittest, we just give
45 // the package name with a --include-lib argument, such as:
46 // --include-lib=unittest. These arguments are collected in
47 // includedLibraries.
42 List<String> includedLibraries = <String>[]; 48 List<String> includedLibraries = <String>[];
49
50 // For libraries that lie within packages but have a different name,
51 // such as the matcher library in package unittest, we can use
52 // --extra-lib with a full relative path under pkg, such as
53 // --extra-lib=unittest/lib/matcher.dart. These arguments are
54 // collected in extraLibraries.
55 List<String> extraLibraries = <String>[];
56
43 String packageRoot; 57 String packageRoot;
44 String version; 58 String version;
45 59
46 // Parse the command-line arguments. 60 // Parse the command-line arguments.
47 for (int i = 0; i < args.length; i++) { 61 for (int i = 0; i < args.length; i++) {
48 final arg = args[i]; 62 final arg = args[i];
49 63
50 switch (arg) { 64 switch (arg) {
51 case '--mode=static': 65 case '--mode=static':
52 mode = MODE_STATIC; 66 mode = MODE_STATIC;
53 break; 67 break;
54 68
55 case '--mode=live-nav': 69 case '--mode=live-nav':
56 mode = MODE_LIVE_NAV; 70 mode = MODE_LIVE_NAV;
57 break; 71 break;
58 72
59 case '--generate-app-cache=true': 73 case '--generate-app-cache=true':
60 generateAppCache = true; 74 generateAppCache = true;
61 break; 75 break;
62 76
63 default: 77 default:
64 if (arg.startsWith('--exclude-lib=')) { 78 if (arg.startsWith('--exclude-lib=')) {
65 excludedLibraries.add(arg.substring('--exclude-lib='.length)); 79 excludedLibraries.add(arg.substring('--exclude-lib='.length));
66 } else if (arg.startsWith('--include-lib=')) { 80 } else if (arg.startsWith('--include-lib=')) {
67 includedLibraries.add(arg.substring('--include-lib='.length)); 81 includedLibraries.add(arg.substring('--include-lib='.length));
82 } else if (arg.startsWith('--extra-lib=')) {
83 extraLibraries.add(arg.substring('--extra-lib='.length));
68 } else if (arg.startsWith('--out=')) { 84 } else if (arg.startsWith('--out=')) {
69 outputDir = new Path(arg.substring('--out='.length)); 85 outputDir = new Path(arg.substring('--out='.length));
70 } else if (arg.startsWith('--package-root=')) { 86 } else if (arg.startsWith('--package-root=')) {
71 packageRoot = arg.substring('--package-root='.length); 87 packageRoot = arg.substring('--package-root='.length);
72 } else if (arg.startsWith('--version=')) { 88 } else if (arg.startsWith('--version=')) {
73 version = arg.substring('--version='.length); 89 version = arg.substring('--version='.length);
74 } else { 90 } else {
75 print('Unknown option: $arg'); 91 print('Unknown option: $arg');
76 return; 92 return;
77 } 93 }
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 } 149 }
134 150
135 if (new File.fromPath(libPath).existsSync()) { 151 if (new File.fromPath(libPath).existsSync()) {
136 apidocLibraries.add(_pathToFileUri(libPath.toNativePath())); 152 apidocLibraries.add(_pathToFileUri(libPath.toNativePath()));
137 includedLibraries.add(libName); 153 includedLibraries.add(libName);
138 } else { 154 } else {
139 print('Warning: could not find package at $path'); 155 print('Warning: could not find package at $path');
140 } 156 }
141 } 157 }
142 }, onDone: () { 158 }, onDone: () {
159 // Add any --extra libraries that had full pkg paths.
160 // TODO(gram): if the handling of --include-lib libraries in the
161 // listen() block above is cleaned up, then this will need to be
162 // too, as it is a special case of the above.
163 for (var lib in extraLibraries) {
164 var libPath = new Path('../../$lib');
165 if (new File.fromPath(libPath).existsSync()) {
166 apidocLibraries.add(_pathToFileUri(libPath.toNativePath()));
167 var libName = libPath.filename.replaceAll('.dart', '');
168 includedLibraries.add(libName);
169 }
170 }
171
143 final apidoc = new Apidoc(mdn, outputDir, mode, generateAppCache, 172 final apidoc = new Apidoc(mdn, outputDir, mode, generateAppCache,
144 excludedLibraries, version); 173 excludedLibraries, version);
145 apidoc.dartdocPath = 174 apidoc.dartdocPath =
146 scriptDir.append('../../sdk/lib/_internal/dartdoc/'); 175 scriptDir.append('../../sdk/lib/_internal/dartdoc/');
147 // Select the libraries to include in the produced documentation: 176 // Select the libraries to include in the produced documentation:
148 apidoc.includeApi = true; 177 apidoc.includeApi = true;
149 apidoc.includedLibraries = includedLibraries; 178 apidoc.includedLibraries = includedLibraries;
150 179
151 // TODO(amouravski): make apidoc use roughly the same flow as bin/dartdoc. 180 // TODO(amouravski): make apidoc use roughly the same flow as bin/dartdoc.
152 Future.wait([copiedStatic, copiedApiDocStatic, htmlDiff]) 181 Future.wait([copiedStatic, copiedApiDocStatic, htmlDiff])
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 /** Converts a local path string to a `file:` [Uri]. */ 485 /** Converts a local path string to a `file:` [Uri]. */
457 Uri _pathToFileUri(String path) { 486 Uri _pathToFileUri(String path) {
458 path = pathos.absolute(path); 487 path = pathos.absolute(path);
459 if (Platform.operatingSystem != 'windows') { 488 if (Platform.operatingSystem != 'windows') {
460 return Uri.parse('file://$path'); 489 return Uri.parse('file://$path');
461 } else { 490 } else {
462 return Uri.parse('file:///${path.replaceAll("\\", "/")}'); 491 return Uri.parse('file:///${path.replaceAll("\\", "/")}');
463 } 492 }
464 } 493 }
465 494
OLDNEW
« no previous file with comments | « pkg/unittest/lib/unittest.dart ('k') | utils/apidoc/apidoc.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698