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

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 List<String> includedLibraries = <String>[]; 42 List<String> includedLibraries = <String>[];
Andrei Mouravski 2013/05/08 10:43:47 You need to be more clear about this. Why is inclu
gram 2013/05/08 22:14:36 I added some comments in the code, but the long st
43 List<String> extraLibraries = <String>[]; // Libs with explicit paths.
43 String packageRoot; 44 String packageRoot;
44 String version; 45 String version;
45 46
46 // Parse the command-line arguments. 47 // Parse the command-line arguments.
47 for (int i = 0; i < args.length; i++) { 48 for (int i = 0; i < args.length; i++) {
48 final arg = args[i]; 49 final arg = args[i];
49 50
50 switch (arg) { 51 switch (arg) {
51 case '--mode=static': 52 case '--mode=static':
52 mode = MODE_STATIC; 53 mode = MODE_STATIC;
53 break; 54 break;
54 55
55 case '--mode=live-nav': 56 case '--mode=live-nav':
56 mode = MODE_LIVE_NAV; 57 mode = MODE_LIVE_NAV;
57 break; 58 break;
58 59
59 case '--generate-app-cache=true': 60 case '--generate-app-cache=true':
60 generateAppCache = true; 61 generateAppCache = true;
61 break; 62 break;
62 63
63 default: 64 default:
64 if (arg.startsWith('--exclude-lib=')) { 65 if (arg.startsWith('--exclude-lib=')) {
65 excludedLibraries.add(arg.substring('--exclude-lib='.length)); 66 excludedLibraries.add(arg.substring('--exclude-lib='.length));
66 } else if (arg.startsWith('--include-lib=')) { 67 } else if (arg.startsWith('--include-lib=')) {
67 includedLibraries.add(arg.substring('--include-lib='.length)); 68 includedLibraries.add(arg.substring('--include-lib='.length));
69 } else if (arg.startsWith('--extra-lib=')) {
70 extraLibraries.add(arg.substring('--extra-lib='.length));
68 } else if (arg.startsWith('--out=')) { 71 } else if (arg.startsWith('--out=')) {
69 outputDir = new Path(arg.substring('--out='.length)); 72 outputDir = new Path(arg.substring('--out='.length));
70 } else if (arg.startsWith('--package-root=')) { 73 } else if (arg.startsWith('--package-root=')) {
71 packageRoot = arg.substring('--package-root='.length); 74 packageRoot = arg.substring('--package-root='.length);
72 } else if (arg.startsWith('--version=')) { 75 } else if (arg.startsWith('--version=')) {
73 version = arg.substring('--version='.length); 76 version = arg.substring('--version='.length);
74 } else { 77 } else {
75 print('Unknown option: $arg'); 78 print('Unknown option: $arg');
76 return; 79 return;
77 } 80 }
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 } 136 }
134 137
135 if (new File.fromPath(libPath).existsSync()) { 138 if (new File.fromPath(libPath).existsSync()) {
136 apidocLibraries.add(_pathToFileUri(libPath.toNativePath())); 139 apidocLibraries.add(_pathToFileUri(libPath.toNativePath()));
137 includedLibraries.add(libName); 140 includedLibraries.add(libName);
138 } else { 141 } else {
139 print('Warning: could not find package at $path'); 142 print('Warning: could not find package at $path');
140 } 143 }
141 } 144 }
142 }, onDone: () { 145 }, onDone: () {
146 // Add any --extra libraries that had full pkg paths.
Andrei Mouravski 2013/05/08 10:43:47 This feels really hacky, so please add a TODO here
gram 2013/05/08 22:14:36 Done.
147 for (var lib in extraLibraries) {
148 var libPath = new Path('../../$lib');
149 if (new File.fromPath(libPath).existsSync()) {
150 apidocLibraries.add(_pathToFileUri(libPath.toNativePath()));
151 var libName = libPath.filename.replaceAll('.dart', '');
152 includedLibraries.add(libName);
153 }
154 }
155
143 final apidoc = new Apidoc(mdn, outputDir, mode, generateAppCache, 156 final apidoc = new Apidoc(mdn, outputDir, mode, generateAppCache,
144 excludedLibraries, version); 157 excludedLibraries, version);
145 apidoc.dartdocPath = 158 apidoc.dartdocPath =
146 scriptDir.append('../../sdk/lib/_internal/dartdoc/'); 159 scriptDir.append('../../sdk/lib/_internal/dartdoc/');
147 // Select the libraries to include in the produced documentation: 160 // Select the libraries to include in the produced documentation:
148 apidoc.includeApi = true; 161 apidoc.includeApi = true;
149 apidoc.includedLibraries = includedLibraries; 162 apidoc.includedLibraries = includedLibraries;
150 163
151 // TODO(amouravski): make apidoc use roughly the same flow as bin/dartdoc. 164 // TODO(amouravski): make apidoc use roughly the same flow as bin/dartdoc.
152 Future.wait([copiedStatic, copiedApiDocStatic, htmlDiff]) 165 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]. */ 469 /** Converts a local path string to a `file:` [Uri]. */
457 Uri _pathToFileUri(String path) { 470 Uri _pathToFileUri(String path) {
458 path = pathos.absolute(path); 471 path = pathos.absolute(path);
459 if (Platform.operatingSystem != 'windows') { 472 if (Platform.operatingSystem != 'windows') {
460 return Uri.parse('file://$path'); 473 return Uri.parse('file://$path');
461 } else { 474 } else {
462 return Uri.parse('file:///${path.replaceAll("\\", "/")}'); 475 return Uri.parse('file:///${path.replaceAll("\\", "/")}');
463 } 476 }
464 } 477 }
465 478
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