From 9120f2b1fdace527ec88803570743035bc6c929d Mon Sep 17 00:00:00 2001 From: Chris Dickinson Date: Sun, 11 Jan 2015 21:40:45 -0800 Subject: doc: update style for iojs * updates the styling for the iojs docs * pulls the processing step for markdown files into a separate module * adds the ability to insert comments into the markdown PR-URL: https://github.com/iojs/io.js/pull/297 Fixes: https://github.com/iojs/iojs.github.io/issues/23 Reviewed-By: Ben Noordhuis Reviewed-By: Colin Ihrig --- tools/doc/generate.js | 41 ++--------------------------------------- 1 file changed, 2 insertions(+), 39 deletions(-) (limited to 'tools/doc/generate.js') diff --git a/tools/doc/generate.js b/tools/doc/generate.js index 2bab2f3ef3..768f3b32e1 100755 --- a/tools/doc/generate.js +++ b/tools/doc/generate.js @@ -20,6 +20,7 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. +var processIncludes = require('./preprocess.js'); var marked = require('marked'); var fs = require('fs'); var path = require('path'); @@ -52,48 +53,10 @@ console.error('Input file = %s', inputFile); fs.readFile(inputFile, 'utf8', function(er, input) { if (er) throw er; // process the input for @include lines - processIncludes(input, next); + processIncludes(inputFile, input, next); }); -var includeExpr = /^@include\s+([A-Za-z0-9-_]+)(?:\.)?([a-zA-Z]*)$/gmi; -var includeData = {}; -function processIncludes(input, cb) { - var includes = input.match(includeExpr); - if (includes === null) return cb(null, input); - var errState = null; - console.error(includes); - var incCount = includes.length; - if (incCount === 0) cb(null, input); - includes.forEach(function(include) { - var fname = include.replace(/^@include\s+/, ''); - if (!fname.match(/\.markdown$/)) fname += '.markdown'; - - if (includeData.hasOwnProperty(fname)) { - input = input.split(include).join(includeData[fname]); - incCount--; - if (incCount === 0) { - return cb(null, input); - } - } - - var fullFname = path.resolve(path.dirname(inputFile), fname); - fs.readFile(fullFname, 'utf8', function(er, inc) { - if (errState) return; - if (er) return cb(errState = er); - processIncludes(inc, function(er, inc) { - if (errState) return; - if (er) return cb(errState = er); - incCount--; - includeData[fname] = inc; - input = input.split(include+'\n').join(includeData[fname]+'\n'); - if (incCount === 0) { - return cb(null, input); - } - }); - }); - }); -} function next(er, input) { -- cgit v1.2.3