From e95689ab841d375800aebae2df113afc7f023025 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paul=20O=E2=80=99Shannessy?= Date: Wed, 16 Sep 2015 14:09:52 -0700 Subject: [PATCH] [docs] Remove unused file --- extractCode.js | 39 --------------------------------------- 1 file changed, 39 deletions(-) delete mode 100644 extractCode.js diff --git a/extractCode.js b/extractCode.js deleted file mode 100644 index 867118eb..00000000 --- a/extractCode.js +++ /dev/null @@ -1,39 +0,0 @@ -'use strict'; - -var argv = require('optimist').argv; -var fs = require('fs'); - -var CODE_SAMPLE = /```[\S]+\s*[\s\S]*?```/g; -var PARTS = /```[\S]+\s*\/\/\s+(.+?)\n([\s\S]*?)```/; - -function truncate(s, n) { - n = n || 256; - if (s.length < n) { - return s; - } - return s.substring(0, n) + '...'; -} - -function main(dest, filenames) { - if (!dest) { - throw new Error('no dest provided'); - } - filenames.map(function(filename) { - var content = fs.readFileSync(filename).toString('utf8'); - var codeSamples = content.match(CODE_SAMPLE); - - codeSamples.map(function(codeSample) { - // Do a little jank preprocessing - codeSample = codeSample.replace('', ''); - var extracted = codeSample.match(PARTS); - if (!extracted) { - throw new Error('Code sample did not match correct format in ' + filename + ': ' + truncate(codeSample)); - } - var codeSampleFilename = extracted[1]; - var codeSampleContent = extracted[2].replace(/\*\*/g, ''); - fs.writeFileSync(argv.dest + '/' + codeSampleFilename, codeSampleContent); - }); - }); -} - -main(argv.dest, argv._);