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

Unified Diff: utils/apidoc/mdn/search.js

Issue 9225039: Integrate MDN content into API documentation. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Respond to review. Created 8 years, 11 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/postProcess.dart ('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/search.js
diff --git a/utils/apidoc/mdn/search.js b/utils/apidoc/mdn/search.js
new file mode 100644
index 0000000000000000000000000000000000000000..c1970783577e40c683be21b3e4c2c0b7af4bc8c5
--- /dev/null
+++ b/utils/apidoc/mdn/search.js
@@ -0,0 +1,58 @@
+/**
+ * Uses a Google Custom Search Engine to find pages on
+ * developer.mozilla.org that appear to match types from the Webkit IDL
+ */
+var https = require('https');
+var fs = require('fs');
+
+var domTypes = JSON.parse(fs.readFileSync('data/domTypes.json', 'utf8'));
+
+try {
+ fs.mkdirSync('output');
+ fs.mkdirSync('output/search');
+} catch (e) {
+ // It doesn't matter if the directories already exist.
+}
+
+function searchForType(type) {
+ // Strip off WebKit specific prefixes from type names to increase the chances
+ // of getting matches on developer.mozilla.org.
+ var shortType = type.replace(/^WebKit/, "");
+
+ // We use a Google Custom Search Engine provisioned for 10,000 API based
+ // queries per day that limits search results to developer.mozilla.org.
+ // You shouldn't need to, but if you want to create your own Google Custom
+ // Search Engine, visit http://www.google.com/cse/
+ var options = {
+ host: 'www.googleapis.com',
+ path: '/customsearch/v1?key=AIzaSyDN1RhE5FafLzLfErGpoYhHlLHeyEkxTkM&' +
+ 'cx=017193972565947830266:wpqsk6dy6ee&num=5&q=' + shortType,
+ port: 443,
+ method: 'GET'
+ };
+
+ var req = https.request(options, function(res) {
+ res.setEncoding('utf8');
+ var data = '';
+ res.on('data', function(d) {
+ data += d;
+ });
+ var onClose = function(e) {
+ fs.writeFile("output/search/" + type + ".json", data, function(err) {
+ if (err) throw err;
+ console.log('Done searching for ' + type);
+ });
+ }
+ res.on('close', onClose);
+ res.on('end', onClose);
+ });
+ req.end();
+
+ req.on('error', function(e) {
+ console.error(e);
+ });
+}
+
+for (var i = 0; i < domTypes.length; i++) {
+ searchForType(domTypes[i]);
+}
« no previous file with comments | « utils/apidoc/mdn/postProcess.dart ('k') | utils/apidoc/static/apidoc-styles.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698