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

Side by Side Diff: pkg/dartdoc/bin/dartdoc.dart

Issue 10950025: Dartdoc supports package directory. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 3 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 | « no previous file | pkg/dartdoc/lib/dartdoc.dart » ('j') | utils/apidoc/apidoc.dart » ('J')
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 * To generate docs for a library, run this script with the path to an 6 * To generate docs for a library, run this script with the path to an
7 * entrypoint .dart file, like: 7 * entrypoint .dart file, like:
8 * 8 *
9 * $ dart dartdoc.dart foo.dart 9 * $ dart dartdoc.dart foo.dart
10 * 10 *
(...skipping 17 matching lines...) Expand all
28 main() { 28 main() {
29 // Need this because ArgParser.getUsage doesn't show command invocation. 29 // Need this because ArgParser.getUsage doesn't show command invocation.
30 final USAGE = 'Usage dartdoc [options] <entrypoint(s)>\n[options] include:'; 30 final USAGE = 'Usage dartdoc [options] <entrypoint(s)>\n[options] include:';
31 31
32 final args = new Options().arguments; 32 final args = new Options().arguments;
33 33
34 final dartdoc = new Dartdoc(); 34 final dartdoc = new Dartdoc();
35 35
36 final argParser = new ArgParser(); 36 final argParser = new ArgParser();
37 37
38 final libPath = scriptDir.append('../../../');
Lasse Reichstein Nielsen 2012/09/19 12:06:49 final what? I'm guessing Path, but please write it
Bob Nystrom 2012/09/19 16:17:17 For what it's worth, most of the Dartdoc codebase
39 Path pkgPath = scriptDir.append('../../../pkg/');
40
38 argParser.addFlag('no-code', 41 argParser.addFlag('no-code',
39 help: 'Do not include source code in the documentation.', 42 help: 'Do not include source code in the documentation.',
40 defaultsTo: false, negatable: false, 43 defaultsTo: false, negatable: false,
41 callback: (noCode) => dartdoc.includeSource = !noCode); 44 callback: (noCode) => dartdoc.includeSource = !noCode);
42 45
43 argParser.addOption('mode', abbr: 'm', 46 argParser.addOption('mode', abbr: 'm',
44 help: 'Define how HTML pages are generated.', 47 help: 'Define how HTML pages are generated.',
45 allowed: ['static', 'live-nav'], allowedHelp: { 48 allowed: ['static', 'live-nav'], allowedHelp: {
46 'static': 'Generates completely static HTML containing\n' 49 'static': 'Generates completely static HTML containing\n'
47 'everything you need to browse the docs. The only\n' 50 'everything you need to browse the docs. The only\n'
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 for(final lst in excLibs) { 140 for(final lst in excLibs) {
138 var someLibs = lst.split(','); 141 var someLibs = lst.split(',');
139 for(final lib in someLibs) { 142 for(final lib in someLibs) {
140 allLibs.add(lib); 143 allLibs.add(lib);
141 } 144 }
142 } 145 }
143 dartdoc.excludedLibraries = allLibs; 146 dartdoc.excludedLibraries = allLibs;
144 } 147 }
145 }, allowMultiple: true); 148 }, allowMultiple: true);
146 149
147 final libPath = scriptDir.append('../../../'); 150 argParser.addOption('pkg',
148 dartdoc.dartdocPath = libPath.append('pkg/dartdoc'); 151 help: 'Sets the package directory to the specified directory.\n'
152 'If omitted the package directory is the SDK pkg/ dir',
153 callback: (pkgDir) {
154 if(pkgDir != null) {
155 pkgPath = new Path.fromNative(pkgDir);
156 }
157 });
158
159 dartdoc.dartdocPath = libPath.append('pkg/dartdoc');
Lasse Reichstein Nielsen 2012/09/19 12:06:49 bad indent?
Johnni Winther 2012/09/20 08:55:59 Done.
149 160
150 if (args.isEmpty()) { 161 if (args.isEmpty()) {
151 print('No arguments provided.'); 162 print('No arguments provided.');
152 print(USAGE); 163 print(USAGE);
153 print(argParser.getUsage()); 164 print(argParser.getUsage());
154 return; 165 return;
155 } 166 }
156 167
157 final entrypoints = <Path>[]; 168 final entrypoints = <Path>[];
158 try { 169 try {
159 final option = argParser.parse(args); 170 final option = argParser.parse(args);
160 for(final arg in option.rest) { 171 for(final arg in option.rest) {
161 entrypoints.add(new Path.fromNative(arg)); 172 entrypoints.add(new Path.fromNative(arg));
162 } 173 }
163 } on FormatException catch (e) { 174 } on FormatException catch (e) {
164 print(e.message); 175 print(e.message);
165 print(USAGE); 176 print(USAGE);
166 print(argParser.getUsage()); 177 print(argParser.getUsage());
167 return; 178 return;
168 } 179 }
169 180
170 if (entrypoints.isEmpty()) { 181 if (entrypoints.isEmpty()) {
171 print('No entrypoints provided.'); 182 print('No entrypoints provided.');
172 print(argParser.getUsage()); 183 print(argParser.getUsage());
173 return; 184 return;
174 } 185 }
175 186
176 cleanOutputDirectory(dartdoc.outputDir); 187 cleanOutputDirectory(dartdoc.outputDir);
177 188
178 dartdoc.documentLibraries(entrypoints, libPath); 189 dartdoc.documentLibraries(entrypoints, libPath, pkgPath);
179 190
180 Future compiled = compileScript(dartdoc.mode, dartdoc.outputDir, libPath); 191 Future compiled = compileScript(dartdoc.mode, dartdoc.outputDir, libPath);
181 Future filesCopied = copyDirectory(scriptDir.append('../static'), 192 Future filesCopied = copyDirectory(scriptDir.append('../static'),
182 dartdoc.outputDir); 193 dartdoc.outputDir);
183 194
184 Futures.wait([compiled, filesCopied]).then((_) { 195 Futures.wait([compiled, filesCopied]).then((_) {
185 dartdoc.cleanup(); 196 dartdoc.cleanup();
186 print('Documented ${dartdoc.totalLibraries} libraries, ' 197 print('Documented ${dartdoc.totalLibraries} libraries, '
187 '${dartdoc.totalTypes} types, and ${dartdoc.totalMembers} members.'); 198 '${dartdoc.totalTypes} types, and ${dartdoc.totalMembers} members.');
188 }); 199 });
189 } 200 }
OLDNEW
« no previous file with comments | « no previous file | pkg/dartdoc/lib/dartdoc.dart » ('j') | utils/apidoc/apidoc.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698