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