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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 } else { | 55 } else { |
56 print('Unknown option: $arg'); | 56 print('Unknown option: $arg'); |
57 return; | 57 return; |
58 } | 58 } |
59 break; | 59 break; |
60 } | 60 } |
61 } | 61 } |
62 | 62 |
63 doc.cleanOutputDirectory(outputDir); | 63 doc.cleanOutputDirectory(outputDir); |
64 | 64 |
65 // Compile the client-side code to JS. | |
66 // TODO(bob): Right path. | |
67 | |
68 final clientScript = (mode == doc.MODE_STATIC) ? | |
69 'static' : 'live-nav'; | |
70 final Future compiled = doc.compileScript( | |
71 doc.scriptDir.append('../../pkg/dartdoc/client-$clientScript.dart'), | |
72 outputDir.append('client-$clientScript.js')); | |
73 | |
74 // TODO(rnystrom): Use platform-specific path separator. | |
75 // The basic dartdoc-provided static content. | 65 // The basic dartdoc-provided static content. |
76 final Future copiedStatic = doc.copyDirectory( | 66 final Future copiedStatic = doc.copyDirectory( |
77 doc.scriptDir.append('../../pkg/dartdoc/static'), | 67 doc.scriptDir.append('../../pkg/dartdoc/static'), |
78 outputDir); | 68 outputDir); |
79 | 69 |
80 // The apidoc-specific static content. | 70 // The apidoc-specific static content. |
81 final Future copiedApiDocStatic = doc.copyDirectory( | 71 final Future copiedApiDocStatic = doc.copyDirectory( |
82 doc.scriptDir.append('static'), | 72 doc.scriptDir.append('static'), |
83 outputDir); | 73 outputDir); |
84 | 74 |
(...skipping 22 matching lines...) Expand all Loading... |
107 DART2JS_LIBRARY_MAP.forEach((String name, LibraryInfo info) { | 97 DART2JS_LIBRARY_MAP.forEach((String name, LibraryInfo info) { |
108 if (!info.isInternal) { | 98 if (!info.isInternal) { |
109 apidocLibraries.add(new Path('dart:$name')); | 99 apidocLibraries.add(new Path('dart:$name')); |
110 } | 100 } |
111 }); | 101 }); |
112 apidocLibraries.add(doc.scriptDir.append('../../pkg/unittest/unittest.dart')); | 102 apidocLibraries.add(doc.scriptDir.append('../../pkg/unittest/unittest.dart')); |
113 apidocLibraries.add(doc.scriptDir.append('../../pkg/i18n/intl.dart')); | 103 apidocLibraries.add(doc.scriptDir.append('../../pkg/i18n/intl.dart')); |
114 | 104 |
115 print('Generating docs...'); | 105 print('Generating docs...'); |
116 final apidoc = new Apidoc(mdn, htmldoc, outputDir, mode, generateAppCache); | 106 final apidoc = new Apidoc(mdn, htmldoc, outputDir, mode, generateAppCache); |
| 107 apidoc.dartdocPath = doc.scriptDir.append('../../pkg/dartdoc/'); |
117 // Select the libraries to include in the produced documentation: | 108 // Select the libraries to include in the produced documentation: |
118 apidoc.includeApi = true; | 109 apidoc.includeApi = true; |
119 apidoc.includedLibraries = <String>[ | 110 apidoc.includedLibraries = <String>[ |
120 'unittest', | 111 'unittest', |
121 'intl', | 112 'intl', |
122 ]; | 113 ]; |
123 | 114 |
| 115 apidoc.documentLibraries(apidocLibraries, doc.libPath); |
| 116 |
| 117 // Compile the client-side code to JS. |
| 118 |
| 119 final clientScript = (mode == doc.MODE_STATIC) ? |
| 120 'static' : 'live-nav'; |
| 121 final Future compiled = doc.compileScript( |
| 122 apidoc.dartdocPath.append('client-$clientScript.dart'), |
| 123 outputDir.append('client-$clientScript.js')); |
| 124 |
124 Futures.wait([compiled, copiedStatic, copiedApiDocStatic]).then((_) { | 125 Futures.wait([compiled, copiedStatic, copiedApiDocStatic]).then((_) { |
125 apidoc.documentLibraries(apidocLibraries, doc.libPath); | 126 apidoc.cleanup(); |
126 }); | 127 }); |
127 } | 128 } |
128 | 129 |
129 /** | 130 /** |
130 * This class is purely here to scrape handwritten HTML documentation. | 131 * This class is purely here to scrape handwritten HTML documentation. |
131 * This scraped documentation will later be merged with the generated | 132 * This scraped documentation will later be merged with the generated |
132 * HTML library. | 133 * HTML library. |
133 */ | 134 */ |
134 class Htmldoc extends doc.Dartdoc { | 135 class Htmldoc extends doc.Dartdoc { |
135 String libraryComment; | 136 String libraryComment; |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 '''); | 322 '''); |
322 } | 323 } |
323 | 324 |
324 void docIndexLibrary(LibraryMirror library) { | 325 void docIndexLibrary(LibraryMirror library) { |
325 // TODO(rnystrom): Hackish. The IO libraries reference this but we don't | 326 // TODO(rnystrom): Hackish. The IO libraries reference this but we don't |
326 // want it in the docs. | 327 // want it in the docs. |
327 if (library.simpleName == 'dart:nativewrappers') return; | 328 if (library.simpleName == 'dart:nativewrappers') return; |
328 super.docIndexLibrary(library); | 329 super.docIndexLibrary(library); |
329 } | 330 } |
330 | 331 |
331 void docLibraryNavigationJson(LibraryMirror library, Map libraryMap) { | 332 void docLibraryNavigationJson(LibraryMirror library, List libraryList) { |
332 // TODO(rnystrom): Hackish. The IO libraries reference this but we don't | 333 // TODO(rnystrom): Hackish. The IO libraries reference this but we don't |
333 // want it in the docs. | 334 // want it in the docs. |
334 if (library.simpleName == 'dart:nativewrappers') return; | 335 if (library.simpleName == 'dart:nativewrappers') return; |
335 super.docLibraryNavigationJson(library, libraryMap); | 336 super.docLibraryNavigationJson(library, libraryList); |
336 } | 337 } |
337 | 338 |
338 void docLibrary(LibraryMirror library) { | 339 void docLibrary(LibraryMirror library) { |
339 // TODO(rnystrom): Hackish. The IO libraries reference this but we don't | 340 // TODO(rnystrom): Hackish. The IO libraries reference this but we don't |
340 // want it in the docs. | 341 // want it in the docs. |
341 if (library.simpleName == 'dart:nativewrappers') return; | 342 if (library.simpleName == 'dart:nativewrappers') return; |
342 super.docLibrary(library); | 343 super.docLibrary(library); |
343 } | 344 } |
344 | 345 |
345 /** Override definition from parent class to strip out annotation tags. */ | 346 /** Override definition from parent class to strip out annotation tags. */ |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
515 final typeName = member.surroundingDeclaration.simpleName; | 516 final typeName = member.surroundingDeclaration.simpleName; |
516 var memberName = '$typeName.${member.simpleName}'; | 517 var memberName = '$typeName.${member.simpleName}'; |
517 if (member is MethodMirror && (member.isConstructor || member.isFactory)) { | 518 if (member is MethodMirror && (member.isConstructor || member.isFactory)) { |
518 final separator = member.constructorName == '' ? '' : '.'; | 519 final separator = member.constructorName == '' ? '' : '.'; |
519 memberName = 'new $typeName$separator${member.constructorName}'; | 520 memberName = 'new $typeName$separator${member.constructorName}'; |
520 } | 521 } |
521 | 522 |
522 return a(memberUrl(member), memberName); | 523 return a(memberUrl(member), memberName); |
523 } | 524 } |
524 } | 525 } |
OLD | NEW |