| OLD | NEW |
| 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 * |
| 11 * This will create a "docs" directory with the docs for your libraries. To | 11 * This will create a "docs" directory with the docs for your libraries. To |
| 12 * create these beautiful docs, dartdoc parses your library and every library | 12 * create these beautiful docs, dartdoc parses your library and every library |
| 13 * it imports (recursively). From each library, it parses all classes and | 13 * it imports (recursively). From each library, it parses all classes and |
| 14 * members, finds the associated doc comments and builds crosslinked docs from | 14 * members, finds the associated doc comments and builds crosslinked docs from |
| 15 * them. | 15 * them. |
| 16 */ | 16 */ |
| 17 library dartdoc; | 17 library dartdoc; |
| 18 | 18 |
| 19 import 'dart:io'; | 19 import 'dart:io'; |
| 20 | 20 |
| 21 // TODO(rnystrom): Use "package:" URL (#4968). | 21 // TODO(rnystrom): Use "package:" URL (#4968). |
| 22 import '../lib/dartdoc.dart'; | 22 import '../lib/dartdoc.dart'; |
| 23 import '../../args/lib/args.dart'; | 23 import '../../../../../pkg/args/lib/args.dart'; |
| 24 | 24 |
| 25 /** | 25 /** |
| 26 * Run this from the `pkg/dartdoc` directory. | 26 * Run this from the `lib/_internal/dartdoc` directory. |
| 27 */ | 27 */ |
| 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 Path libPath = scriptDir.append('../../../'); | 38 final Path libPath = scriptDir.append('../../../../'); |
| 39 Path pkgPath = scriptDir.append('../../../pkg/'); | 39 Path pkgPath = scriptDir.append('../../../../pkg/'); |
| 40 | 40 |
| 41 argParser.addFlag('no-code', | 41 argParser.addFlag('no-code', |
| 42 help: 'Do not include source code in the documentation.', | 42 help: 'Do not include source code in the documentation.', |
| 43 defaultsTo: false, negatable: false, | 43 defaultsTo: false, negatable: false, |
| 44 callback: (noCode) => dartdoc.includeSource = !noCode); | 44 callback: (noCode) => dartdoc.includeSource = !noCode); |
| 45 | 45 |
| 46 argParser.addOption('mode', abbr: 'm', | 46 argParser.addOption('mode', abbr: 'm', |
| 47 help: 'Define how HTML pages are generated.', | 47 help: 'Define how HTML pages are generated.', |
| 48 allowed: ['static', 'live-nav'], allowedHelp: { | 48 allowed: ['static', 'live-nav'], allowedHelp: { |
| 49 'static': 'Generates completely static HTML containing\n' | 49 'static': 'Generates completely static HTML containing\n' |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 | 159 |
| 160 argParser.addOption('pkg', | 160 argParser.addOption('pkg', |
| 161 help: 'Sets the package directory to the specified directory.\n' | 161 help: 'Sets the package directory to the specified directory.\n' |
| 162 'If omitted the package directory is the SDK pkg/ dir', | 162 'If omitted the package directory is the SDK pkg/ dir', |
| 163 callback: (pkgDir) { | 163 callback: (pkgDir) { |
| 164 if(pkgDir != null) { | 164 if(pkgDir != null) { |
| 165 pkgPath = new Path.fromNative(pkgDir); | 165 pkgPath = new Path.fromNative(pkgDir); |
| 166 } | 166 } |
| 167 }); | 167 }); |
| 168 | 168 |
| 169 dartdoc.dartdocPath = libPath.append('pkg/dartdoc'); | 169 dartdoc.dartdocPath = libPath.append('lib/_internal/dartdoc'); |
| 170 | 170 |
| 171 if (args.isEmpty) { | 171 if (args.isEmpty) { |
| 172 print('No arguments provided.'); | 172 print('No arguments provided.'); |
| 173 print(USAGE); | 173 print(USAGE); |
| 174 print(argParser.getUsage()); | 174 print(argParser.getUsage()); |
| 175 return; | 175 return; |
| 176 } | 176 } |
| 177 | 177 |
| 178 final entrypoints = <Path>[]; | 178 final entrypoints = <Path>[]; |
| 179 try { | 179 try { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 201 Future compiled = compileScript(dartdoc.mode, dartdoc.outputDir, libPath); | 201 Future compiled = compileScript(dartdoc.mode, dartdoc.outputDir, libPath); |
| 202 Future filesCopied = copyDirectory(scriptDir.append('../static'), | 202 Future filesCopied = copyDirectory(scriptDir.append('../static'), |
| 203 dartdoc.outputDir); | 203 dartdoc.outputDir); |
| 204 | 204 |
| 205 Futures.wait([compiled, filesCopied]).then((_) { | 205 Futures.wait([compiled, filesCopied]).then((_) { |
| 206 dartdoc.cleanup(); | 206 dartdoc.cleanup(); |
| 207 print('Documented ${dartdoc.totalLibraries} libraries, ' | 207 print('Documented ${dartdoc.totalLibraries} libraries, ' |
| 208 '${dartdoc.totalTypes} types, and ${dartdoc.totalMembers} members.'); | 208 '${dartdoc.totalTypes} types, and ${dartdoc.totalMembers} members.'); |
| 209 }); | 209 }); |
| 210 } | 210 } |
| OLD | NEW |