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 * 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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
97 | 97 |
98 print('Cross-referencing dart:html...'); | 98 print('Cross-referencing dart:html...'); |
99 // TODO(amouravski): move HtmlDiff inside of the future chain below to re-use | 99 // TODO(amouravski): move HtmlDiff inside of the future chain below to re-use |
100 // the MirrorSystem already analyzed. | 100 // the MirrorSystem already analyzed. |
101 _diff = new HtmlDiff(printWarnings:false); | 101 _diff = new HtmlDiff(printWarnings:false); |
102 Future htmlDiff = _diff.run(libPath); | 102 Future htmlDiff = _diff.run(libPath); |
103 | 103 |
104 // TODO(johnniwinther): Libraries for the compilation seem to be more like | 104 // TODO(johnniwinther): Libraries for the compilation seem to be more like |
105 // URIs. Perhaps Path should have a toURI() method. | 105 // URIs. Perhaps Path should have a toURI() method. |
106 // Add all of the core libraries. | 106 // Add all of the core libraries. |
107 final apidocLibraries = <Path>[]; | 107 final apidocLibraries = <Uri>[]; |
108 LIBRARIES.forEach((String name, LibraryInfo info) { | 108 LIBRARIES.forEach((String name, LibraryInfo info) { |
109 if (info.documented) { | 109 if (info.documented) { |
110 apidocLibraries.add(new Path('dart:$name')); | 110 apidocLibraries.add(Uri.parse('dart:$name')); |
111 } | 111 } |
112 }); | 112 }); |
113 | 113 |
114 // TODO(amouravski): This code is really wonky. | 114 // TODO(amouravski): This code is really wonky. |
115 var lister = new Directory.fromPath(scriptDir.append('../../pkg')).list(); | 115 var lister = new Directory.fromPath(scriptDir.append('../../pkg')).list(); |
116 lister.listen((entity) { | 116 lister.listen((entity) { |
117 if (entity is Directory) { | 117 if (entity is Directory) { |
118 var path = new Path(entity.path); | 118 var path = new Path(entity.path); |
119 var libName = path.filename; | 119 var libName = path.filename; |
120 var libPath = path.append('lib/$libName.dart'); | 120 var libPath = path.append('lib/$libName.dart'); |
121 | 121 |
122 // Ignore some libraries. | 122 // Ignore some libraries. |
123 if (excludedLibraries.contains(libName)) { | 123 if (excludedLibraries.contains(libName)) { |
124 return; | 124 return; |
125 } | 125 } |
126 | 126 |
127 // Ignore hidden directories (like .svn) as well as pkg.xcodeproj. | 127 // Ignore hidden directories (like .svn) as well as pkg.xcodeproj. |
128 if (libName.startsWith('.') || libName.endsWith('.xcodeproj')) { | 128 if (libName.startsWith('.') || libName.endsWith('.xcodeproj')) { |
129 return; | 129 return; |
130 } | 130 } |
131 | 131 |
132 if (new File.fromPath(libPath).existsSync()) { | 132 if (new File.fromPath(libPath).existsSync()) { |
133 apidocLibraries.add(libPath); | 133 apidocLibraries.add(_pathToFileUri(libPath.toNativePath())); |
134 includedLibraries.add(libName); | 134 includedLibraries.add(libName); |
135 } else { | 135 } else { |
136 print('Warning: could not find package at $path'); | 136 print('Warning: could not find package at $path'); |
137 } | 137 } |
138 } | 138 } |
139 }, onDone: () { | 139 }, onDone: () { |
140 final apidoc = new Apidoc(mdn, outputDir, mode, generateAppCache, | 140 final apidoc = new Apidoc(mdn, outputDir, mode, generateAppCache, |
141 excludedLibraries, version); | 141 excludedLibraries, version); |
142 apidoc.dartdocPath = | 142 apidoc.dartdocPath = |
143 scriptDir.append('../../sdk/lib/_internal/dartdoc/'); | 143 scriptDir.append('../../sdk/lib/_internal/dartdoc/'); |
144 // Select the libraries to include in the produced documentation: | 144 // Select the libraries to include in the produced documentation: |
145 apidoc.includeApi = true; | 145 apidoc.includeApi = true; |
146 apidoc.includedLibraries = includedLibraries; | 146 apidoc.includedLibraries = includedLibraries; |
147 | 147 |
148 // TODO(amouravski): make apidoc use roughly the same flow as bin/dartdoc. | 148 // TODO(amouravski): make apidoc use roughly the same flow as bin/dartdoc. |
149 Future.wait([copiedStatic, copiedApiDocStatic, htmlDiff]) | 149 Future.wait([copiedStatic, copiedApiDocStatic, htmlDiff]) |
150 .then((_) => apidoc.documentLibraries( apidocLibraries, libPath, | 150 .then((_) => apidoc.documentLibraries(apidocLibraries, libPath, |
151 packageRoot)) | 151 packageRoot)) |
152 .then((_) => compileScript(mode, outputDir, libPath)) | 152 .then((_) => compileScript(mode, outputDir, libPath)) |
153 .then((_) => print(apidoc.status)) | 153 .then((_) => print(apidoc.status)) |
154 .catchError((e) { | 154 .catchError((e) { |
155 print('Error: generation failed: ${e}'); | 155 print('Error: generation failed: ${e}'); |
156 apidoc.cleanup(); | 156 apidoc.cleanup(); |
157 exit(1); | 157 exit(1); |
158 }) | 158 }) |
159 .whenComplete(() => apidoc.cleanup()); | 159 .whenComplete(() => apidoc.cleanup()); |
160 }); | 160 }); |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
440 final typeName = member.owner.simpleName; | 440 final typeName = member.owner.simpleName; |
441 var memberName = '$typeName.${member.simpleName}'; | 441 var memberName = '$typeName.${member.simpleName}'; |
442 if (member is MethodMirror && (member.isConstructor || member.isFactory)) { | 442 if (member is MethodMirror && (member.isConstructor || member.isFactory)) { |
443 final separator = member.constructorName == '' ? '' : '.'; | 443 final separator = member.constructorName == '' ? '' : '.'; |
444 memberName = 'new $typeName$separator${member.constructorName}'; | 444 memberName = 'new $typeName$separator${member.constructorName}'; |
445 } | 445 } |
446 | 446 |
447 return a(memberUrl(member), memberName); | 447 return a(memberUrl(member), memberName); |
448 } | 448 } |
449 } | 449 } |
450 | |
451 /** Converts a local path string to a `file:` [Uri]. */ | |
Andrei Mouravski
2013/04/09 01:48:36
Instead of copypasta, import dartdoc/utils
nweiz
2013/04/09 02:10:23
I don't like importing utils across projects. It b
Andrei Mouravski
2013/04/09 02:13:49
In which case, putting the function into lib/dartd
| |
452 Uri _pathToFileUri(String pathString) { | |
453 pathString = path.absolute(pathString); | |
454 if (Platform.operatingSystem != 'windows') { | |
455 return Uri.parse('file://$pathString'); | |
456 } else { | |
457 return Uri.parse('file:///${pathString.replaceAll("\\", "/")}'); | |
458 } | |
459 } | |
460 | |
OLD | NEW |