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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 } | 119 } |
120 }); | 120 }); |
121 | 121 |
122 argParser.addOption('include-lib', | 122 argParser.addOption('include-lib', |
123 help: 'Use this option to explicitly specify which\n' | 123 help: 'Use this option to explicitly specify which\n' |
124 'libraries to include in the documentation. If\n' | 124 'libraries to include in the documentation. If\n' |
125 'omitted, all used libraries are included by\n' | 125 'omitted, all used libraries are included by\n' |
126 'default. Specify a comma-separated list of\n' | 126 'default. Specify a comma-separated list of\n' |
127 'library names, or call this option multiple times.', | 127 'library names, or call this option multiple times.', |
128 callback: (incLibs) { | 128 callback: (incLibs) { |
129 if(!incLibs.isEmpty()) { | 129 if(!incLibs.isEmpty) { |
130 List<String> allLibs = new List<String>(); | 130 List<String> allLibs = new List<String>(); |
131 for(final lst in incLibs) { | 131 for(final lst in incLibs) { |
132 var someLibs = lst.split(','); | 132 var someLibs = lst.split(','); |
133 for(final lib in someLibs) { | 133 for(final lib in someLibs) { |
134 allLibs.add(lib); | 134 allLibs.add(lib); |
135 } | 135 } |
136 } | 136 } |
137 dartdoc.excludedLibraries = allLibs; | 137 dartdoc.excludedLibraries = allLibs; |
138 } | 138 } |
139 }, allowMultiple: true); | 139 }, allowMultiple: true); |
140 | 140 |
141 argParser.addOption('exclude-lib', | 141 argParser.addOption('exclude-lib', |
142 help: 'Use this option to explicitly specify which\n' | 142 help: 'Use this option to explicitly specify which\n' |
143 'libraries to exclude from the documentation. If\n' | 143 'libraries to exclude from the documentation. If\n' |
144 'omitted, no libraries are excluded. Specify a\n' | 144 'omitted, no libraries are excluded. Specify a\n' |
145 'comma-separated list of library names, or call\n' | 145 'comma-separated list of library names, or call\n' |
146 'this option multiple times.', | 146 'this option multiple times.', |
147 callback: (excLibs) { | 147 callback: (excLibs) { |
148 if(!excLibs.isEmpty()) { | 148 if(!excLibs.isEmpty) { |
149 List<String> allLibs = new List<String>(); | 149 List<String> allLibs = new List<String>(); |
150 for(final lst in excLibs) { | 150 for(final lst in excLibs) { |
151 var someLibs = lst.split(','); | 151 var someLibs = lst.split(','); |
152 for(final lib in someLibs) { | 152 for(final lib in someLibs) { |
153 allLibs.add(lib); | 153 allLibs.add(lib); |
154 } | 154 } |
155 } | 155 } |
156 dartdoc.excludedLibraries = allLibs; | 156 dartdoc.excludedLibraries = allLibs; |
157 } | 157 } |
158 }, allowMultiple: true); | 158 }, allowMultiple: true); |
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('pkg/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 { |
180 final option = argParser.parse(args); | 180 final option = argParser.parse(args); |
181 for(final arg in option.rest) { | 181 for(final arg in option.rest) { |
182 entrypoints.add(new Path.fromNative(arg)); | 182 entrypoints.add(new Path.fromNative(arg)); |
183 } | 183 } |
184 } on FormatException catch (e) { | 184 } on FormatException catch (e) { |
185 print(e.message); | 185 print(e.message); |
186 print(USAGE); | 186 print(USAGE); |
187 print(argParser.getUsage()); | 187 print(argParser.getUsage()); |
188 return; | 188 return; |
189 } | 189 } |
190 | 190 |
191 if (entrypoints.isEmpty()) { | 191 if (entrypoints.isEmpty) { |
192 print('No entrypoints provided.'); | 192 print('No entrypoints provided.'); |
193 print(argParser.getUsage()); | 193 print(argParser.getUsage()); |
194 return; | 194 return; |
195 } | 195 } |
196 | 196 |
197 cleanOutputDirectory(dartdoc.outputDir); | 197 cleanOutputDirectory(dartdoc.outputDir); |
198 | 198 |
199 dartdoc.documentLibraries(entrypoints, libPath, pkgPath); | 199 dartdoc.documentLibraries(entrypoints, libPath, pkgPath); |
200 | 200 |
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 |