diff options
author | Chris Dickinson <christopher.s.dickinson@gmail.com> | 2015-01-11 21:40:45 -0800 |
---|---|---|
committer | Chris Dickinson <christopher.s.dickinson@gmail.com> | 2015-01-12 13:44:50 -0800 |
commit | 9120f2b1fdace527ec88803570743035bc6c929d (patch) | |
tree | eae06cf867a3f4cd431d5233ead54a22eaae1fb4 /tools/doc/generate.js | |
parent | 3a85eac4ec7ff8a1700ddec21e0177d2f60335ea (diff) | |
download | android-node-v8-9120f2b1fdace527ec88803570743035bc6c929d.tar.gz android-node-v8-9120f2b1fdace527ec88803570743035bc6c929d.tar.bz2 android-node-v8-9120f2b1fdace527ec88803570743035bc6c929d.zip |
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 <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Diffstat (limited to 'tools/doc/generate.js')
-rwxr-xr-x | tools/doc/generate.js | 41 |
1 files changed, 2 insertions, 39 deletions
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) { |