| 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 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 } | 177 } |
| 178 | 178 |
| 179 // Suppress any actual writing to file. This is only for analysis. | 179 // Suppress any actual writing to file. This is only for analysis. |
| 180 void endFile() { | 180 void endFile() { |
| 181 } | 181 } |
| 182 | 182 |
| 183 void write(String s) { | 183 void write(String s) { |
| 184 } | 184 } |
| 185 | 185 |
| 186 doc.DocComment getRecordedLibraryComment(LibraryMirror library) { | 186 doc.DocComment getRecordedLibraryComment(LibraryMirror library) { |
| 187 if (doc.displayName(library) == HTML_LIBRARY_NAME) { | 187 if (HTML_LIBRARY_NAMES.contains(doc.displayName(library))) { |
| 188 return libraryComment; | 188 return libraryComment; |
| 189 } | 189 } |
| 190 return null; | 190 return null; |
| 191 } | 191 } |
| 192 | 192 |
| 193 doc.DocComment getRecordedTypeComment(TypeMirror type) { | 193 doc.DocComment getRecordedTypeComment(TypeMirror type) { |
| 194 if (typeComments.containsKey(type.qualifiedName)) { | 194 if (typeComments.containsKey(type.qualifiedName)) { |
| 195 return typeComments[type.qualifiedName]; | 195 return typeComments[type.qualifiedName]; |
| 196 } | 196 } |
| 197 return null; | 197 return null; |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 doc.DocComment createDocComment(String text, | 382 doc.DocComment createDocComment(String text, |
| 383 [ClassMirror inheritedFrom]) { | 383 [ClassMirror inheritedFrom]) { |
| 384 String strippedText = | 384 String strippedText = |
| 385 text.replaceAll(const RegExp("@([a-zA-Z]+) ([^;]+)(?:;|\$)"), | 385 text.replaceAll(const RegExp("@([a-zA-Z]+) ([^;]+)(?:;|\$)"), |
| 386 '').trim(); | 386 '').trim(); |
| 387 if (strippedText.isEmpty) return null; | 387 if (strippedText.isEmpty) return null; |
| 388 return super.createDocComment(strippedText, inheritedFrom); | 388 return super.createDocComment(strippedText, inheritedFrom); |
| 389 } | 389 } |
| 390 | 390 |
| 391 doc.DocComment getLibraryComment(LibraryMirror library) { | 391 doc.DocComment getLibraryComment(LibraryMirror library) { |
| 392 if (doc.displayName(library) == HTML_LIBRARY_NAME) { | 392 if (HTML_LIBRARY_NAMES.contains(doc.displayName(library))) { |
| 393 return htmldoc.libraryComment; | 393 return htmldoc.libraryComment; |
| 394 } | 394 } |
| 395 return super.getLibraryComment(library); | 395 return super.getLibraryComment(library); |
| 396 } | 396 } |
| 397 | 397 |
| 398 doc.DocComment getTypeComment(TypeMirror type) { | 398 doc.DocComment getTypeComment(TypeMirror type) { |
| 399 return _mergeDocs( | 399 return _mergeDocs( |
| 400 includeMdnTypeComment(type), super.getTypeComment(type), | 400 includeMdnTypeComment(type), super.getTypeComment(type), |
| 401 htmldoc.getRecordedTypeComment(type)); | 401 htmldoc.getRecordedTypeComment(type)); |
| 402 } | 402 } |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 462 * Gets the MDN-scraped docs for [type], or `null` if this type isn't | 462 * Gets the MDN-scraped docs for [type], or `null` if this type isn't |
| 463 * scraped from MDN. | 463 * scraped from MDN. |
| 464 */ | 464 */ |
| 465 MdnComment includeMdnTypeComment(TypeMirror type) { | 465 MdnComment includeMdnTypeComment(TypeMirror type) { |
| 466 if (_mdnTypeNamesToSkip.contains(type.simpleName)) { | 466 if (_mdnTypeNamesToSkip.contains(type.simpleName)) { |
| 467 print('Skipping MDN type ${type.simpleName}'); | 467 print('Skipping MDN type ${type.simpleName}'); |
| 468 return null; | 468 return null; |
| 469 } | 469 } |
| 470 | 470 |
| 471 var typeString = ''; | 471 var typeString = ''; |
| 472 if (doc.displayName(type.library) == HTML_LIBRARY_NAME) { | 472 if (HTML_LIBRARY_NAMES.contains(doc.displayName(type.library))) { |
| 473 // If it's an HTML type, try to map it to a base DOM type so we can find | 473 // If it's an HTML type, try to map it to a base DOM type so we can find |
| 474 // the MDN docs. | 474 // the MDN docs. |
| 475 final domTypes = _diff.htmlTypesToDom[type.qualifiedName]; | 475 final domTypes = _diff.htmlTypesToDom[type.qualifiedName]; |
| 476 | 476 |
| 477 // Couldn't find a DOM type. | 477 // Couldn't find a DOM type. |
| 478 if ((domTypes == null) || (domTypes.length != 1)) return null; | 478 if ((domTypes == null) || (domTypes.length != 1)) return null; |
| 479 | 479 |
| 480 // Use the corresponding DOM type when searching MDN. | 480 // Use the corresponding DOM type when searching MDN. |
| 481 // TODO(rnystrom): Shame there isn't a simpler way to get the one item | 481 // TODO(rnystrom): Shame there isn't a simpler way to get the one item |
| 482 // out of a singleton Set. | 482 // out of a singleton Set. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 496 return new MdnComment(mdnType['summary'], mdnType['srcUrl']); | 496 return new MdnComment(mdnType['summary'], mdnType['srcUrl']); |
| 497 } | 497 } |
| 498 | 498 |
| 499 /** | 499 /** |
| 500 * Gets the MDN-scraped docs for [member], or `null` if this type isn't | 500 * Gets the MDN-scraped docs for [member], or `null` if this type isn't |
| 501 * scraped from MDN. | 501 * scraped from MDN. |
| 502 */ | 502 */ |
| 503 MdnComment includeMdnMemberComment(MemberMirror member) { | 503 MdnComment includeMdnMemberComment(MemberMirror member) { |
| 504 var library = findLibrary(member); | 504 var library = findLibrary(member); |
| 505 var memberString = ''; | 505 var memberString = ''; |
| 506 if (doc.displayName(library) == HTML_LIBRARY_NAME) { | 506 if (HTML_LIBRARY_NAMES.contains(doc.displayName(library))) { |
| 507 // If it's an HTML type, try to map it to a DOM type name so we can find | 507 // If it's an HTML type, try to map it to a DOM type name so we can find |
| 508 // the MDN docs. | 508 // the MDN docs. |
| 509 final domMembers = _diff.htmlToDom[member.qualifiedName]; | 509 final domMembers = _diff.htmlToDom[member.qualifiedName]; |
| 510 | 510 |
| 511 // Couldn't find a DOM type. | 511 // Couldn't find a DOM type. |
| 512 if ((domMembers == null) || (domMembers.length != 1)) return null; | 512 if ((domMembers == null) || (domMembers.length != 1)) return null; |
| 513 | 513 |
| 514 // Use the corresponding DOM member when searching MDN. | 514 // Use the corresponding DOM member when searching MDN. |
| 515 // TODO(rnystrom): Shame there isn't a simpler way to get the one item | 515 // TODO(rnystrom): Shame there isn't a simpler way to get the one item |
| 516 // out of a singleton Set. | 516 // out of a singleton Set. |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 578 return ''' | 578 return ''' |
| 579 <div class="mdn"> | 579 <div class="mdn"> |
| 580 $mdnComment | 580 $mdnComment |
| 581 <div class="mdn-note"><a href="$mdnUrl">from MDN</a></div> | 581 <div class="mdn-note"><a href="$mdnUrl">from MDN</a></div> |
| 582 </div> | 582 </div> |
| 583 '''; | 583 '''; |
| 584 } | 584 } |
| 585 | 585 |
| 586 String toString() => mdnComment; | 586 String toString() => mdnComment; |
| 587 } | 587 } |
| OLD | NEW |