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

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

Issue 1361163002: remove docgen remnants from repo, update CHANGELOG (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: remove unused code Created 5 years, 3 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 | « utils/apidoc/mdn/search.js ('k') | utils/apidoc/static/apidoc-styles.css » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: utils/apidoc/mdn/util.dart
diff --git a/utils/apidoc/mdn/util.dart b/utils/apidoc/mdn/util.dart
deleted file mode 100644
index e5907bde3202f95782aea85b1f5487b49552c177..0000000000000000000000000000000000000000
--- a/utils/apidoc/mdn/util.dart
+++ /dev/null
@@ -1,95 +0,0 @@
-library util;
-
-import 'dart:io';
-
-Map<String, Map> _allProps;
-
-Map<String, Map> get allProps {
- if (_allProps == null) {
- // Database of expected property names for each type in WebKit.
- _allProps = parse.parse(
- new File('data/dartIdl.json').readAsStringSync());
- }
- 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.keys) {
- 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;
-}
-
-/**
- * Helper for sync creation of a whole file from a string.
- */
-void writeFileSync(String filename, String data) {
- File f = new File(filename);
- RandomAccessFile raf = f.openSync(FileMode.WRITE);
- raf.writeStringSync(data);
- raf.closeSync();
-}
« no previous file with comments | « utils/apidoc/mdn/search.js ('k') | utils/apidoc/static/apidoc-styles.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698