Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Unified Diff: client/html/scripts/html_doc.dart

Issue 8973004: Move Nathan's HTML scripts over and rename to apidoc. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « client/html/scripts/html_diff.dart ('k') | utils/apidoc/.gitignore » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: client/html/scripts/html_doc.dart
diff --git a/client/html/scripts/html_doc.dart b/client/html/scripts/html_doc.dart
deleted file mode 100644
index 784fb5013abf5b36f5cbf73718ff8741d8d72893..0000000000000000000000000000000000000000
--- a/client/html/scripts/html_doc.dart
+++ /dev/null
@@ -1,139 +0,0 @@
-// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-/**
- * A script to document the HTML library, including annotations on the mapping
- * to and from the DOM library. To use it, from utils/dartdoc, run:
- *
- * $ htmldoc
- *
- * This works just like `dartdoc html`, with the additions of the DOM/HTML
- * mapping documentation.
- */
-#library('html_doc');
-
-#import('html_diff.dart');
-#import('../../../frog/lang.dart');
-#import('../../../frog/file_system_node.dart');
-#import('../../../frog/file_system.dart');
-#import('../../../utils/dartdoc/dartdoc.dart', prefix: 'doc');
-
-HtmlDiff _diff;
-
-void main() {
- var files = new NodeFileSystem();
- parseOptions('../../frog', [] /* args */, files);
- initializeWorld(files);
- final htmldoc = new Htmldoc();
- HtmlDiff.initialize();
-
- _diff = new HtmlDiff();
- _diff.run();
- world.reset();
-
- htmldoc.document('html');
-}
-
-class Htmldoc extends doc.Dartdoc {
- getTypeComment(Type type) {
- return _mergeComments(super.getTypeComment(type), getTypeDoc(type));
- }
-
- getMethodComment(MethodMember method) {
- return _mergeComments(super.getMethodComment(method), getMemberDoc(method));
- }
-
- getFieldComment(FieldMember field) {
- return _mergeComments(super.getFieldComment(field), getMemberDoc(field));
- }
-
- String _mergeComments(String comment, String extra) {
- if (comment == null) return extra;
- return '$comment\n\n$extra';
- }
-}
-
-/**
- * Returns a Markdown-formatted link to [member], relative to a type page that
- * may be in a different library than [member].
- */
-String _linkMember(Member member) {
- final typeName = member.declaringType.name;
- var memberName = "$typeName.${member.name}";
- if (member.isConstructor || member.isFactory) {
- final separator = member.constructorName == '' ? '' : '.';
- memberName = 'new $typeName$separator${member.constructorName}';
- } else if (member.name.startsWith('get:')) {
- memberName = "$typeName.${member.name.substring(4)}";
- }
-
- return "[$memberName](../${doc.memberUrl(member)})";
-}
-
-/**
- * Returns a Markdown-formatted link to [type], relative to a type page that
- * may be in a different library than [type].
- */
-String _linkType(Type type) => "[${type.name}](../${doc.typeUrl(type)})";
-
-/**
- * Unify getters and setters of the same property. We only want to print
- * explicit setters if no getter exists.
- *
- * If [members] contains no setters, returns it unmodified.
- */
-Set<Member> _unifyProperties(Set<Member> members) {
- // Only print setters if the getter doesn't exist.
- return members.filter((m) {
- if (!m.name.startsWith('set:')) return true;
- var getName = m.name.replaceFirst('set:', 'get:');
- return !members.some((maybeGet) => maybeGet.name == getName);
- });
-}
-
-/**
- * Returns additional Markdown-formatted documentation for [member], linking it
- * to the corresponding `dart:html` or `dart:dom` [Member](s). If [member] is
- * not in `dart:html` or `dart:dom`, returns no additional documentation.
- */
-String getMemberDoc(Member member) {
- if (_diff.domToHtml.containsKey(member)) {
- final htmlMemberSet = _unifyProperties(_diff.domToHtml[member]);
- final allSameName = htmlMemberSet.every((m) => _diff.sameName(member, m));
- final phrase = allSameName ? "available as" : "renamed to";
- final htmlMembers = doc.joinWithCommas(map(htmlMemberSet, _linkMember));
- return "_This is $phrase $htmlMembers in the " +
- "[dart:html](../html.html) library._";
- } else if (_diff.htmlToDom.containsKey(member)) {
- final domMemberSet = _unifyProperties(_diff.htmlToDom[member]);
- final allSameName = domMemberSet.every((m) => _diff.sameName(m, member));
- final phrase = allSameName ? "is the same as" : "renames";
- final domMembers = doc.joinWithCommas(map(domMemberSet, _linkMember));
- return "_This $phrase $domMembers in the [dart:dom](../dom.html) " +
- "library._";
- } else {
- return "";
- }
-}
-
-/**
- * Returns additional Markdown-formatted documentation for [type], linking it to
- * the corresponding `dart:html` or `dart:dom` [Type](s). If [type] is not in
- * `dart:html` or `dart:dom`, returns no additional documentation.
- */
-String getTypeDoc(Type type) {
- if (_diff.domTypesToHtml.containsKey(type)) {
- var htmlTypes = doc.joinWithCommas(
- map(_diff.domTypesToHtml[type], _linkType));
- return "_This corresponds to $htmlTypes in the [dart:html](../html.html) " +
- "library._";
- } else if (_diff.htmlTypesToDom.containsKey(type)) {
- var domTypes = doc.joinWithCommas(
- map(_diff.htmlTypesToDom[type], _linkType));
- return "_This corresponds to $domTypes in the [dart:dom](../dom.html) " +
- "library._";
- } else {
- return "";
- }
-}
« no previous file with comments | « client/html/scripts/html_diff.dart ('k') | utils/apidoc/.gitignore » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698