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

Unified Diff: lib/dartdoc/utils.dart

Issue 10701091: Dartdoc and Apidoc updated to use dart2js through the mirror system. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixed cf. rnystrom's comments. Created 8 years, 5 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: lib/dartdoc/utils.dart
diff --git a/lib/dartdoc/utils.dart b/lib/dartdoc/utils.dart
index b2e5758375bb9ca3feb3b83d7bbd78b94813220b..9e0400826f635e3f07ae238f0a495116c269e363 100644
--- a/lib/dartdoc/utils.dart
+++ b/lib/dartdoc/utils.dart
@@ -47,20 +47,16 @@ String unindent(String text, int indentation) {
}
/** Sorts the map by the key, doing a case-insensitive comparison. */
-List orderByName(Map<String, Dynamic> map) {
- List keys = map.getKeys();
- keys.sort((a, b) {
- // Hack: make sure $dom methods show up last in the list not first.
- String transformName(String name) =>
- name.toUpperCase().replaceFirst(const RegExp('\\\$DOM_'), 'zzzz');
-
- return transformName(a).compareTo(transformName(b));
+List<Mirror> orderByName(List<Mirror> list) {
+ final elements = new List<Mirror>.from(list);
+ elements.sort((a,b) {
+ String aName = a.simpleName();
+ String bName = b.simpleName();
+ bool doma = aName.startsWith(@"$dom");
+ bool domb = bName.startsWith(@"$dom");
+ return doma == domb ? aName.compareTo(bName) : doma ? 1 : -1;
});
- final values = [];
- for (var k in keys) {
- values.add(map[k]);
- }
- return values;
+ return elements;
}
/**
@@ -70,6 +66,12 @@ List orderByName(Map<String, Dynamic> map) {
String joinWithCommas(List<String> items, [String conjunction = 'and']) {
if (items.length == 1) return items[0];
if (items.length == 2) return "${items[0]} $conjunction ${items[1]}";
- return Strings.join(items.getRange(0, items.length - 1), ', ') +
- ', $conjunction ' + items[items.length - 1];
+ return '${Strings.join(items.getRange(0, items.length - 1), ', ')}'
+ ', $conjunction ${items[items.length - 1]}';
+}
+
+void writeString(File file, String text) {
+ var randomAccessFile = file.openSync(FileMode.WRITE);
+ randomAccessFile.writeStringSync(text);
+ randomAccessFile.closeSync();
}

Powered by Google App Engine
This is Rietveld 408576698