| 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 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 if (library.simpleName == 'dart:nativewrappers') return; | 368 if (library.simpleName == '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 (library.simpleName == 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 |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 474 typeString = domTypes.iterator().next(); | 474 typeString = domTypes.iterator().next(); |
| 475 } else { | 475 } else { |
| 476 // Not a DOM type. | 476 // Not a DOM type. |
| 477 return null; | 477 return null; |
| 478 } | 478 } |
| 479 | 479 |
| 480 final mdnType = mdn[typeString]; | 480 final mdnType = mdn[typeString]; |
| 481 if (mdnType == null) return null; | 481 if (mdnType == null) return null; |
| 482 if (mdnType['skipped'] != null) return null; | 482 if (mdnType['skipped'] != null) return null; |
| 483 if (mdnType['summary'] == null) return null; | 483 if (mdnType['summary'] == null) return null; |
| 484 if (mdnType['summary'].trim().isEmpty()) return null; | 484 if (mdnType['summary'].trim().isEmpty) return null; |
| 485 | 485 |
| 486 // Remember which MDN page we're using so we can attribute it. | 486 // Remember which MDN page we're using so we can attribute it. |
| 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) { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 524 for (final candidateMember in mdnType['members']) { | 524 for (final candidateMember in mdnType['members']) { |
| 525 if (candidateMember['name'] == nameToFind) { | 525 if (candidateMember['name'] == nameToFind) { |
| 526 mdnMember = candidateMember; | 526 mdnMember = candidateMember; |
| 527 break; | 527 break; |
| 528 } | 528 } |
| 529 } | 529 } |
| 530 } | 530 } |
| 531 | 531 |
| 532 if (mdnMember == null) return null; | 532 if (mdnMember == null) return null; |
| 533 if (mdnMember['help'] == null) return null; | 533 if (mdnMember['help'] == null) return null; |
| 534 if (mdnMember['help'].trim().isEmpty()) return null; | 534 if (mdnMember['help'].trim().isEmpty) return null; |
| 535 | 535 |
| 536 // Remember which MDN page we're using so we can attribute it. | 536 // Remember which MDN page we're using so we can attribute it. |
| 537 return new MdnComment(mdnMember['help'], mdnType['srcUrl']); | 537 return new MdnComment(mdnMember['help'], mdnType['srcUrl']); |
| 538 } | 538 } |
| 539 | 539 |
| 540 /** | 540 /** |
| 541 * Returns a link to [member], relative to a type page that may be in a | 541 * Returns a link to [member], relative to a type page that may be in a |
| 542 * different library than [member]. | 542 * different library than [member]. |
| 543 */ | 543 */ |
| 544 String _linkMember(MemberMirror member) { | 544 String _linkMember(MemberMirror member) { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 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 |