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

Unified Diff: utils/dartdoc/html_renderer.dart

Issue 9555013: Get dartdoc in the SDK and working correctly. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Update copyright date. Created 8 years, 10 months 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
Index: utils/dartdoc/html_renderer.dart
diff --git a/utils/dartdoc/html_renderer.dart b/utils/dartdoc/html_renderer.dart
deleted file mode 100644
index 14b7bb03fd0b72a779dab12c1746c635f89ea5f7..0000000000000000000000000000000000000000
--- a/utils/dartdoc/html_renderer.dart
+++ /dev/null
@@ -1,59 +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.
-
-String renderToHtml(List<Node> nodes) => new HtmlRenderer().render(nodes);
-
-/// Translates a parsed AST to HTML.
-class HtmlRenderer implements NodeVisitor {
- static final _BLOCK_TAGS = const RegExp(
- 'blockquote|h1|h2|h3|h4|h5|h6|hr|p|pre');
-
- StringBuffer buffer;
-
- HtmlRenderer();
-
- String render(List<Node> nodes) {
- buffer = new StringBuffer();
-
- for (final node in nodes) node.accept(this);
-
- return buffer.toString();
- }
-
- void visitText(Text text) {
- buffer.add(text.text);
- }
-
- bool visitElementBefore(Element element) {
- // Hackish. Separate block-level elements with newlines.
- if (!buffer.isEmpty() &&
- _BLOCK_TAGS.firstMatch(element.tag) != null) {
- buffer.add('\n');
- }
-
- buffer.add('<${element.tag}');
-
- // Sort the keys so that we generate stable output.
- // TODO(rnystrom): This assumes getKeys() returns a fresh mutable
- // collection.
- final attributeNames = element.attributes.getKeys();
- attributeNames.sort((a, b) => a.compareTo(b));
- for (final name in attributeNames) {
- buffer.add(' $name="${element.attributes[name]}"');
- }
-
- if (element.isEmpty) {
- // Empty element like <hr/>.
- buffer.add(' />');
- return false;
- } else {
- buffer.add('>');
- return true;
- }
- }
-
- void visitElementAfter(Element element) {
- buffer.add('</${element.tag}>');
- }
-}
« frog/presubmit.py ('K') | « utils/dartdoc/dartdoc.dart ('k') | utils/dartdoc/htmldoc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698