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

Unified Diff: dart/utils/apidoc/mdn/util.dart

Issue 10164004: Remove frogsh. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 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
Index: dart/utils/apidoc/mdn/util.dart
diff --git a/dart/utils/apidoc/mdn/util.dart b/dart/utils/apidoc/mdn/util.dart
deleted file mode 100644
index fa940e9b805c026222bbbf6d8c34a27b20520126..0000000000000000000000000000000000000000
--- a/dart/utils/apidoc/mdn/util.dart
+++ /dev/null
@@ -1,85 +0,0 @@
-#library("util");
-
-#import("../../../frog/lib/node/node.dart");
-#import("dart:json");
-
-Map<String, Map> _allProps;
-
-Map<String, Map> get allProps() {
- if (_allProps == null) {
- // Database of expected property names for each type in WebKit.
- _allProps = JSON.parse(fs.readFileSync('data/dartIdl.json', 'utf8'));
- }
- return _allProps;
-}
-
-Set<String> matchedTypes;
-
-/** Returns whether the type has any member matching the specified name. */
-bool hasAny(String type, String prop) {
- final data = allProps[type];
- return data['properties'].containsKey(prop) ||
- data['methods'].containsKey(prop) ||
- data['constants'].containsKey(prop);
-}
-
-/**
- * Return the members from an [entry] as Map of member names to member
- * objects.
- */
-Map getMembersMap(Map entry) {
- List<Map> rawMembers = entry["members"];
- final members = {};
- for (final entry in rawMembers) {
- members[entry['name']] = entry;
- }
- return members;
-}
-
-/**
- * Score entries using similarity heuristics calculated from the observed and
- * expected list of members. We could be much less naive and penalize spurious
- * methods, prefer entries with class level comments, etc. This method is
- * needed becase we extract entries for each of the top search results for
- * each class name and rely on these scores to determine which entry was
- * best. Typically all scores but one will be zero. Multiple pages have
- * non-zero scores when MDN has multiple pages on the same class or pages on
- * similar classes (e.g. HTMLElement and Element), or pages on Mozilla
- * specific classes that are similar to DOM classes (Console).
- */
-num scoreEntry(Map entry, String type) {
- num score = 0;
- // TODO(jacobr): consider removing skipped entries completely instead of
- // just giving them lower scores.
- if (!entry.containsKey('skipped')) {
- score++;
- }
- if (entry.containsKey("members")) {
- Map members = getMembersMap(entry);
- for (String name in members.getKeys()) {
- if (hasAny(type, name)) {
- score++;
- }
- }
- }
- return score;
-}
-
-/**
- * Given a list of candidates for the documentation for a type, find the one
- * that is the best.
- */
-Map pickBestEntry(List entries, String type) {
- num bestScore = -1;
- Map bestEntry;
- for (Map entry in entries) {
- if (entry != null) {
- num score = scoreEntry(entry, type);
- if (score > bestScore) {
- bestScore = score;
- bestEntry = entry;
- }
- }
- }
- return bestEntry;
-}

Powered by Google App Engine
This is Rietveld 408576698