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

Side by Side Diff: utils/apidoc/apidoc.dart

Issue 12217077: Generate separate json files for each library. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: PTAL Created 7 years, 10 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
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 18 matching lines...) Expand all
29 void main() { 29 void main() {
30 final args = new Options().arguments; 30 final args = new Options().arguments;
31 31
32 int mode = doc.MODE_STATIC; 32 int mode = doc.MODE_STATIC;
33 Path outputDir = new Path('docs'); 33 Path outputDir = new Path('docs');
34 bool generateAppCache = false; 34 bool generateAppCache = false;
35 35
36 List<String> excludedLibraries = <String>[]; 36 List<String> excludedLibraries = <String>[];
37 List<String> includedLibraries = <String>[]; 37 List<String> includedLibraries = <String>[];
38 var pkgPath; 38 var pkgPath;
39 39 String version;
40 40
41 // Parse the command-line arguments. 41 // Parse the command-line arguments.
42 for (int i = 0; i < args.length; i++) { 42 for (int i = 0; i < args.length; i++) {
43 final arg = args[i]; 43 final arg = args[i];
44 44
45 switch (arg) { 45 switch (arg) {
46 case '--mode=static': 46 case '--mode=static':
47 mode = doc.MODE_STATIC; 47 mode = doc.MODE_STATIC;
48 break; 48 break;
49 49
50 case '--mode=live-nav': 50 case '--mode=live-nav':
51 mode = doc.MODE_LIVE_NAV; 51 mode = doc.MODE_LIVE_NAV;
52 break; 52 break;
53 53
54 case '--generate-app-cache=true': 54 case '--generate-app-cache=true':
55 generateAppCache = true; 55 generateAppCache = true;
56 break; 56 break;
57 57
58 default: 58 default:
59 if (arg.startsWith('--exclude-lib=')) { 59 if (arg.startsWith('--exclude-lib=')) {
60 excludedLibraries.add(arg.substring('--exclude-lib='.length)); 60 excludedLibraries.add(arg.substring('--exclude-lib='.length));
61 } else if (arg.startsWith('--include-lib=')) { 61 } else if (arg.startsWith('--include-lib=')) {
62 includedLibraries.add(arg.substring('--include-lib='.length)); 62 includedLibraries.add(arg.substring('--include-lib='.length));
63 } else if (arg.startsWith('--out=')) { 63 } else if (arg.startsWith('--out=')) {
64 outputDir = new Path(arg.substring('--out='.length)); 64 outputDir = new Path(arg.substring('--out='.length));
65 } else if (arg.startsWith('--pkg=')) { 65 } else if (arg.startsWith('--pkg=')) {
66 pkgPath = new Path(arg.substring('--pkg='.length)); 66 pkgPath = arg.substring('--pkg='.length);
67 } else if (arg.startsWith('--version=')) {
68 version = arg.substring('--version='.length);
67 } else { 69 } else {
68 print('Unknown option: $arg'); 70 print('Unknown option: $arg');
69 return; 71 return;
70 } 72 }
71 break; 73 break;
72 } 74 }
73 } 75 }
74 76
75 final libPath = doc.scriptDir.append('../../sdk/'); 77 final libPath = doc.scriptDir.append('../../sdk/');
76 78
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 apidocLibraries.add(newStylePath); 126 apidocLibraries.add(newStylePath);
125 includedLibraries.add(libName); 127 includedLibraries.add(libName);
126 } else { 128 } else {
127 print('Warning: could not find package at $path'); 129 print('Warning: could not find package at $path');
128 } 130 }
129 }; 131 };
130 132
131 lister.onDone = (success) { 133 lister.onDone = (success) {
132 print('Generating docs...'); 134 print('Generating docs...');
133 final apidoc = new Apidoc(mdn, outputDir, mode, generateAppCache, 135 final apidoc = new Apidoc(mdn, outputDir, mode, generateAppCache,
134 excludedLibraries); 136 excludedLibraries, version);
135 apidoc.dartdocPath = 137 apidoc.dartdocPath =
136 doc.scriptDir.append('../../sdk/lib/_internal/dartdoc/'); 138 doc.scriptDir.append('../../sdk/lib/_internal/dartdoc/');
137 // Select the libraries to include in the produced documentation: 139 // Select the libraries to include in the produced documentation:
138 apidoc.includeApi = true; 140 apidoc.includeApi = true;
139 apidoc.includedLibraries = includedLibraries; 141 apidoc.includedLibraries = includedLibraries;
140 142
141 Future.wait([copiedStatic, copiedApiDocStatic]).then((_) { 143 Future.wait([copiedStatic, copiedApiDocStatic]).then((_) {
142 apidoc.documentLibraries(apidocLibraries, libPath, pkgPath); 144 apidoc.documentLibraries(apidocLibraries, libPath, pkgPath);
143 145
144 final compiled = doc.compileScript(mode, outputDir, libPath); 146 final compiled = doc.compileScript(mode, outputDir, libPath);
(...skipping 17 matching lines...) Expand all
162 static Set<String> _mdnTypeNamesToSkip = null; 164 static Set<String> _mdnTypeNamesToSkip = null;
163 165
164 /** 166 /**
165 * The URL to the page on MDN that content was pulled from for the current 167 * The URL to the page on MDN that content was pulled from for the current
166 * type being documented. Will be `null` if the type doesn't use any MDN 168 * type being documented. Will be `null` if the type doesn't use any MDN
167 * content. 169 * content.
168 */ 170 */
169 String mdnUrl = null; 171 String mdnUrl = null;
170 172
171 Apidoc(this.mdn, Path outputDir, int mode, 173 Apidoc(this.mdn, Path outputDir, int mode,
172 bool generateAppCache, [excludedLibraries]) { 174 bool generateAppCache, [excludedLibraries, String version]) {
173 if (?excludedLibraries) { 175 if (?excludedLibraries) {
174 this.excludedLibraries = excludedLibraries; 176 this.excludedLibraries = excludedLibraries;
175 } 177 }
176 178 this.version = version;
177 this.outputDir = outputDir; 179 this.outputDir = outputDir;
178 this.mode = mode; 180 this.mode = mode;
179 this.generateAppCache = generateAppCache; 181 this.generateAppCache = generateAppCache;
180 182
181 // Skip bad entries in the checked-in mdn/database.json: 183 // Skip bad entries in the checked-in mdn/database.json:
182 // * UnknownElement has a top-level Gecko DOM page in German. 184 // * UnknownElement has a top-level Gecko DOM page in German.
183 if (_mdnTypeNamesToSkip == null) 185 if (_mdnTypeNamesToSkip == null)
184 _mdnTypeNamesToSkip = new Set.from(['UnknownElement']); 186 _mdnTypeNamesToSkip = new Set.from(['UnknownElement']);
185 187
186 mainTitle = 'Dart API Reference'; 188 mainTitle = 'Dart API Reference';
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 return ''' 447 return '''
446 <div class="mdn"> 448 <div class="mdn">
447 $mdnComment 449 $mdnComment
448 <div class="mdn-note"><a href="$mdnUrl">from MDN</a></div> 450 <div class="mdn-note"><a href="$mdnUrl">from MDN</a></div>
449 </div> 451 </div>
450 '''; 452 ''';
451 } 453 }
452 454
453 String toString() => mdnComment; 455 String toString() => mdnComment;
454 } 456 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698