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

Unified Diff: pkg/docgen/lib/src/generator.dart

Issue 237343002: pkg/docgen: sort output files (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 8 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
« no previous file with comments | « pkg/docgen/bin/docgen.dart ('k') | pkg/docgen/lib/src/model_helpers.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/docgen/lib/src/generator.dart
diff --git a/pkg/docgen/lib/src/generator.dart b/pkg/docgen/lib/src/generator.dart
index a77531b06e5f2c72cb336794edaa69a1f50aaa20..e1478ff04ee7e51dc2d0eae3b9d241cabaa47684 100644
--- a/pkg/docgen/lib/src/generator.dart
+++ b/pkg/docgen/lib/src/generator.dart
@@ -5,6 +5,7 @@
library docgen.generator;
import 'dart:async';
+import 'dart:collection';
import 'dart:convert';
import 'dart:io';
@@ -171,6 +172,21 @@ String _readIntroductionFile(String fileName, bool includeSdk) {
inlineSyntaxes: MARKDOWN_SYNTAXES);
}
+int _indexableComparer(Indexable a, Indexable b) {
+ if (a is Library && b is Library) {
+ var compare = a.packageName.compareTo(b.packageName);
+ if (compare == 0) {
+ compare = a.name.compareTo(b.name);
+ }
+ return compare;
+ }
+
+ if (a is Library) return -1;
+ if (b is Library) return 1;
+
+ return a.qualifiedName.compareTo(b.qualifiedName);
+}
Alan Knight 2014/04/14 17:33:30 Why can't we just compare the qualified name of li
kevmoo 2014/04/14 17:35:37 Because core libraries don't have a qualified pref
+
/// Creates documentation for filtered libraries.
void _documentLibraries(List<LibraryMirror> libs, {bool includeSdk: false, bool
outputToYaml: true, bool append: false, bool parseSdk: false, String
@@ -182,7 +198,7 @@ void _documentLibraries(List<LibraryMirror> libs, {bool includeSdk: false, bool
}
});
- var filteredEntities = new Set<Indexable>();
+ var filteredEntities = new SplayTreeSet<Indexable>(_indexableComparer);
for (Map<String, Set<Indexable>> firstLevel in mirrorToDocgen.values) {
for (Set<Indexable> items in firstLevel.values) {
for (Indexable item in items) {
@@ -245,8 +261,9 @@ void _writeOutputFiles(Map<String, dynamic> libraryMap, Iterable<Indexable>
'${e.qualifiedName} ${e.typeName}').toList()..sort();
_writeToFile(sortedEntities.join('\n') + '\n', 'index.txt', append: append);
- var index = new Map.fromIterables(filteredEntities.map((e) => e.qualifiedName
- ), filteredEntities.map((e) => e.typeName));
+ var index = new SplayTreeMap.fromIterable(filteredEntities,
+ key: (e) => e.qualifiedName, value: (e) => e.typeName);
+
if (append) {
var previousIndex = JSON.decode(new File('$_outputDirectory/index.json'
).readAsStringSync());
@@ -438,7 +455,6 @@ void generateLibrary(dart2js_mirrors.Dart2JsLibraryMirror library) {
logger.fine('Generated library for ${result.name}');
}
-
/// If we can't find the SDK introduction text, which will happen if running
/// from a snapshot and using --parse-sdk or --include-sdk, then use this
/// hard-coded version. This should be updated to be consistent with the text
« no previous file with comments | « pkg/docgen/bin/docgen.dart ('k') | pkg/docgen/lib/src/model_helpers.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698