Chromium Code Reviews| 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 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 172 } | 172 } |
| 173 | 173 |
| 174 // Suppress any actual writing to file. This is only for analysis. | 174 // Suppress any actual writing to file. This is only for analysis. |
| 175 void endFile() { | 175 void endFile() { |
| 176 } | 176 } |
| 177 | 177 |
| 178 void write(String s) { | 178 void write(String s) { |
| 179 } | 179 } |
| 180 | 180 |
| 181 doc.DocComment getRecordedLibraryComment(LibraryMirror library) { | 181 doc.DocComment getRecordedLibraryComment(LibraryMirror library) { |
| 182 if (library.simpleName == HTML_LIBRARY_NAME) { | 182 if (doc.printedName(library) == HTML_LIBRARY_NAME) { |
| 183 return libraryComment; | 183 return libraryComment; |
| 184 } | 184 } |
| 185 return null; | 185 return null; |
| 186 } | 186 } |
| 187 | 187 |
| 188 doc.DocComment getRecordedTypeComment(TypeMirror type) { | 188 doc.DocComment getRecordedTypeComment(TypeMirror type) { |
| 189 if (typeComments.containsKey(type.qualifiedName)) { | 189 if (typeComments.containsKey(type.qualifiedName)) { |
| 190 return typeComments[type.qualifiedName]; | 190 return typeComments[type.qualifiedName]; |
| 191 } | 191 } |
| 192 return null; | 192 return null; |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 344 var s = document.getElementsByTagName("script")[0]; | 344 var s = document.getElementsByTagName("script")[0]; |
| 345 s.parentNode.insertBefore(ga, s); | 345 s.parentNode.insertBefore(ga, s); |
| 346 })(); | 346 })(); |
| 347 </script> | 347 </script> |
| 348 '''); | 348 '''); |
| 349 } | 349 } |
| 350 | 350 |
| 351 void docIndexLibrary(LibraryMirror library) { | 351 void docIndexLibrary(LibraryMirror library) { |
| 352 // TODO(rnystrom): Hackish. The IO libraries reference this but we don't | 352 // TODO(rnystrom): Hackish. The IO libraries reference this but we don't |
| 353 // want it in the docs. | 353 // want it in the docs. |
| 354 if (library.simpleName == 'dart:nativewrappers') return; | 354 if (doc.printedName(library)== 'dart:nativewrappers') return; |
|
Bob Nystrom
2012/10/24 20:52:15
Space before "==" here and elsewhere.
Andrei Mouravski
2012/10/24 21:19:36
Done.
| |
| 355 super.docIndexLibrary(library); | 355 super.docIndexLibrary(library); |
| 356 } | 356 } |
| 357 | 357 |
| 358 void docLibraryNavigationJson(LibraryMirror library, List libraryList) { | 358 void docLibraryNavigationJson(LibraryMirror library, List libraryList) { |
| 359 // TODO(rnystrom): Hackish. The IO libraries reference this but we don't | 359 // TODO(rnystrom): Hackish. The IO libraries reference this but we don't |
| 360 // want it in the docs. | 360 // want it in the docs. |
| 361 if (library.simpleName == 'dart:nativewrappers') return; | 361 if (doc.printedName(library)== 'dart:nativewrappers') return; |
| 362 super.docLibraryNavigationJson(library, libraryList); | 362 super.docLibraryNavigationJson(library, libraryList); |
| 363 } | 363 } |
| 364 | 364 |
| 365 void docLibrary(LibraryMirror library) { | 365 void docLibrary(LibraryMirror library) { |
| 366 // TODO(rnystrom): Hackish. The IO libraries reference this but we don't | 366 // TODO(rnystrom): Hackish. The IO libraries reference this but we don't |
| 367 // want it in the docs. | 367 // want it in the docs. |
| 368 if (library.simpleName == 'dart:nativewrappers') return; | 368 if (doc.printedName(library)== 'dart:nativewrappers') return; |
| 369 super.docLibrary(library); | 369 super.docLibrary(library); |
| 370 } | 370 } |
| 371 | 371 |
| 372 /** Override definition from parent class to strip out annotation tags. */ | 372 /** Override definition from parent class to strip out annotation tags. */ |
| 373 doc.DocComment createDocComment(String text, | 373 doc.DocComment createDocComment(String text, |
| 374 [InterfaceMirror inheritedFrom]) { | 374 [InterfaceMirror inheritedFrom]) { |
| 375 String strippedText = | 375 String strippedText = |
| 376 text.replaceAll(const RegExp("@([a-zA-Z]+) ([^;]+)(?:;|\$)"), | 376 text.replaceAll(const RegExp("@([a-zA-Z]+) ([^;]+)(?:;|\$)"), |
| 377 '').trim(); | 377 '').trim(); |
| 378 if (strippedText.isEmpty) return null; | 378 if (strippedText.isEmpty) return null; |
| 379 return super.createDocComment(strippedText, inheritedFrom); | 379 return super.createDocComment(strippedText, inheritedFrom); |
| 380 } | 380 } |
| 381 | 381 |
| 382 doc.DocComment getLibraryComment(LibraryMirror library) { | 382 doc.DocComment getLibraryComment(LibraryMirror library) { |
| 383 if (library.simpleName == HTML_LIBRARY_NAME) { | 383 if (doc.printedName(library)== HTML_LIBRARY_NAME) { |
| 384 return htmldoc.libraryComment; | 384 return htmldoc.libraryComment; |
| 385 } | 385 } |
| 386 return super.getLibraryComment(library); | 386 return super.getLibraryComment(library); |
| 387 } | 387 } |
| 388 | 388 |
| 389 doc.DocComment getTypeComment(TypeMirror type) { | 389 doc.DocComment getTypeComment(TypeMirror type) { |
| 390 return _mergeDocs( | 390 return _mergeDocs( |
| 391 includeMdnTypeComment(type), super.getTypeComment(type), | 391 includeMdnTypeComment(type), super.getTypeComment(type), |
| 392 htmldoc.getRecordedTypeComment(type)); | 392 htmldoc.getRecordedTypeComment(type)); |
| 393 } | 393 } |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 453 * Gets the MDN-scraped docs for [type], or `null` if this type isn't | 453 * Gets the MDN-scraped docs for [type], or `null` if this type isn't |
| 454 * scraped from MDN. | 454 * scraped from MDN. |
| 455 */ | 455 */ |
| 456 MdnComment includeMdnTypeComment(TypeMirror type) { | 456 MdnComment includeMdnTypeComment(TypeMirror type) { |
| 457 if (_mdnTypeNamesToSkip.contains(type.simpleName)) { | 457 if (_mdnTypeNamesToSkip.contains(type.simpleName)) { |
| 458 print('Skipping MDN type ${type.simpleName}'); | 458 print('Skipping MDN type ${type.simpleName}'); |
| 459 return null; | 459 return null; |
| 460 } | 460 } |
| 461 | 461 |
| 462 var typeString = ''; | 462 var typeString = ''; |
| 463 if (type.library.simpleName == HTML_LIBRARY_NAME) { | 463 if (doc.printedName(type.library) == HTML_LIBRARY_NAME) { |
| 464 // If it's an HTML type, try to map it to a base DOM type so we can find | 464 // If it's an HTML type, try to map it to a base DOM type so we can find |
| 465 // the MDN docs. | 465 // the MDN docs. |
| 466 final domTypes = _diff.htmlTypesToDom[type.qualifiedName]; | 466 final domTypes = _diff.htmlTypesToDom[type.qualifiedName]; |
| 467 | 467 |
| 468 // Couldn't find a DOM type. | 468 // Couldn't find a DOM type. |
| 469 if ((domTypes == null) || (domTypes.length != 1)) return null; | 469 if ((domTypes == null) || (domTypes.length != 1)) return null; |
| 470 | 470 |
| 471 // Use the corresponding DOM type when searching MDN. | 471 // Use the corresponding DOM type when searching MDN. |
| 472 // TODO(rnystrom): Shame there isn't a simpler way to get the one item | 472 // TODO(rnystrom): Shame there isn't a simpler way to get the one item |
| 473 // out of a singleton Set. | 473 // out of a singleton Set. |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 487 return new MdnComment(mdnType['summary'], mdnType['srcUrl']); | 487 return new MdnComment(mdnType['summary'], mdnType['srcUrl']); |
| 488 } | 488 } |
| 489 | 489 |
| 490 /** | 490 /** |
| 491 * Gets the MDN-scraped docs for [member], or `null` if this type isn't | 491 * Gets the MDN-scraped docs for [member], or `null` if this type isn't |
| 492 * scraped from MDN. | 492 * scraped from MDN. |
| 493 */ | 493 */ |
| 494 MdnComment includeMdnMemberComment(MemberMirror member) { | 494 MdnComment includeMdnMemberComment(MemberMirror member) { |
| 495 var library = findLibrary(member); | 495 var library = findLibrary(member); |
| 496 var memberString = ''; | 496 var memberString = ''; |
| 497 if (library.simpleName == HTML_LIBRARY_NAME) { | 497 if (doc.printedName(library)== HTML_LIBRARY_NAME) { |
| 498 // If it's an HTML type, try to map it to a DOM type name so we can find | 498 // If it's an HTML type, try to map it to a DOM type name so we can find |
| 499 // the MDN docs. | 499 // the MDN docs. |
| 500 final domMembers = _diff.htmlToDom[member.qualifiedName]; | 500 final domMembers = _diff.htmlToDom[member.qualifiedName]; |
| 501 | 501 |
| 502 // Couldn't find a DOM type. | 502 // Couldn't find a DOM type. |
| 503 if ((domMembers == null) || (domMembers.length != 1)) return null; | 503 if ((domMembers == null) || (domMembers.length != 1)) return null; |
| 504 | 504 |
| 505 // Use the corresponding DOM member when searching MDN. | 505 // Use the corresponding DOM member when searching MDN. |
| 506 // TODO(rnystrom): Shame there isn't a simpler way to get the one item | 506 // TODO(rnystrom): Shame there isn't a simpler way to get the one item |
| 507 // out of a singleton Set. | 507 // out of a singleton Set. |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 568 // content that lacks a top-level block tag. | 568 // content that lacks a top-level block tag. |
| 569 return ''' | 569 return ''' |
| 570 <div class="mdn"> | 570 <div class="mdn"> |
| 571 $mdnComment | 571 $mdnComment |
| 572 <div class="mdn-note"><a href="$mdnUrl">from MDN</a></div> | 572 <div class="mdn-note"><a href="$mdnUrl">from MDN</a></div> |
| 573 </div> | 573 </div> |
| 574 '''; | 574 '''; |
| 575 } | 575 } |
| 576 | 576 |
| 577 String toString() => mdnComment; | 577 String toString() => mdnComment; |
| 578 } | 578 } |
| OLD | NEW |