| 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 * |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 defaultsTo: false, negatable: false, | 110 defaultsTo: false, negatable: false, |
| 111 callback: (inherit) => dartdoc.inheritFromObject = inherit); | 111 callback: (inherit) => dartdoc.inheritFromObject = inherit); |
| 112 | 112 |
| 113 argParser.addFlag('enable-diagnostic-colors', negatable: false); | 113 argParser.addFlag('enable-diagnostic-colors', negatable: false); |
| 114 | 114 |
| 115 argParser.addOption('out', | 115 argParser.addOption('out', |
| 116 help: 'Generates files into directory specified. If\n' | 116 help: 'Generates files into directory specified. If\n' |
| 117 'omitted the files are generated into ./docs/', | 117 'omitted the files are generated into ./docs/', |
| 118 callback: (outDir) { | 118 callback: (outDir) { |
| 119 if(outDir != null) { | 119 if(outDir != null) { |
| 120 dartdoc.outputDir = new Path.fromNative(outDir); | 120 dartdoc.outputDir = new Path(outDir); |
| 121 } | 121 } |
| 122 }); | 122 }); |
| 123 | 123 |
| 124 argParser.addOption('include-lib', | 124 argParser.addOption('include-lib', |
| 125 help: 'Use this option to explicitly specify which\n' | 125 help: 'Use this option to explicitly specify which\n' |
| 126 'libraries to include in the documentation. If\n' | 126 'libraries to include in the documentation. If\n' |
| 127 'omitted, all used libraries are included by\n' | 127 'omitted, all used libraries are included by\n' |
| 128 'default. Specify a comma-separated list of\n' | 128 'default. Specify a comma-separated list of\n' |
| 129 'library names, or call this option multiple times.', | 129 'library names, or call this option multiple times.', |
| 130 callback: (incLibs) { | 130 callback: (incLibs) { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 157 } | 157 } |
| 158 dartdoc.excludedLibraries = allLibs; | 158 dartdoc.excludedLibraries = allLibs; |
| 159 } | 159 } |
| 160 }, allowMultiple: true); | 160 }, allowMultiple: true); |
| 161 | 161 |
| 162 argParser.addOption('pkg', | 162 argParser.addOption('pkg', |
| 163 help: 'Sets the package directory to the specified directory.\n' | 163 help: 'Sets the package directory to the specified directory.\n' |
| 164 'If omitted the package directory is the SDK pkg/ dir', | 164 'If omitted the package directory is the SDK pkg/ dir', |
| 165 callback: (pkgDir) { | 165 callback: (pkgDir) { |
| 166 if(pkgDir != null) { | 166 if(pkgDir != null) { |
| 167 pkgPath = new Path.fromNative(pkgDir); | 167 pkgPath = new Path(pkgDir); |
| 168 } | 168 } |
| 169 }); | 169 }); |
| 170 | 170 |
| 171 dartdoc.dartdocPath = libPath.append('lib/_internal/dartdoc'); | 171 dartdoc.dartdocPath = libPath.append('lib/_internal/dartdoc'); |
| 172 | 172 |
| 173 if (args.isEmpty) { | 173 if (args.isEmpty) { |
| 174 print('No arguments provided.'); | 174 print('No arguments provided.'); |
| 175 print(USAGE); | 175 print(USAGE); |
| 176 print(argParser.getUsage()); | 176 print(argParser.getUsage()); |
| 177 exit(1); | 177 exit(1); |
| 178 } | 178 } |
| 179 | 179 |
| 180 final entrypoints = <Path>[]; | 180 final entrypoints = <Path>[]; |
| 181 try { | 181 try { |
| 182 final option = argParser.parse(args); | 182 final option = argParser.parse(args); |
| 183 | 183 |
| 184 // This checks to see if the root of all entrypoints is the same. | 184 // This checks to see if the root of all entrypoints is the same. |
| 185 // If it is not, then we display a warning, as package imports might fail. | 185 // If it is not, then we display a warning, as package imports might fail. |
| 186 var entrypointRoot; | 186 var entrypointRoot; |
| 187 for(final arg in option.rest) { | 187 for(final arg in option.rest) { |
| 188 var entrypoint = new Path.fromNative(arg); | 188 var entrypoint = new Path(arg); |
| 189 entrypoints.add(entrypoint); | 189 entrypoints.add(entrypoint); |
| 190 | 190 |
| 191 if (entrypointRoot == null) { | 191 if (entrypointRoot == null) { |
| 192 entrypointRoot = entrypoint.directoryPath; | 192 entrypointRoot = entrypoint.directoryPath; |
| 193 } else if (entrypointRoot.toNativePath() != | 193 } else if (entrypointRoot.toNativePath() != |
| 194 entrypoint.directoryPath.toNativePath()) { | 194 entrypoint.directoryPath.toNativePath()) { |
| 195 print('Warning: entrypoints are at different directories. "package:"' | 195 print('Warning: entrypoints are at different directories. "package:"' |
| 196 ' imports may fail.'); | 196 ' imports may fail.'); |
| 197 } | 197 } |
| 198 } | 198 } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 220 Future compiled = compileScript(dartdoc.mode, dartdoc.outputDir, libPath); | 220 Future compiled = compileScript(dartdoc.mode, dartdoc.outputDir, libPath); |
| 221 Future filesCopied = copyDirectory(scriptDir.append('../static'), | 221 Future filesCopied = copyDirectory(scriptDir.append('../static'), |
| 222 dartdoc.outputDir); | 222 dartdoc.outputDir); |
| 223 | 223 |
| 224 Future.wait([compiled, filesCopied]).then((_) { | 224 Future.wait([compiled, filesCopied]).then((_) { |
| 225 dartdoc.cleanup(); | 225 dartdoc.cleanup(); |
| 226 print('Documented ${dartdoc.totalLibraries} libraries, ' | 226 print('Documented ${dartdoc.totalLibraries} libraries, ' |
| 227 '${dartdoc.totalTypes} types, and ${dartdoc.totalMembers} members.'); | 227 '${dartdoc.totalTypes} types, and ${dartdoc.totalMembers} members.'); |
| 228 }); | 228 }); |
| 229 } | 229 } |
| OLD | NEW |