Exemplo n.º 1
0
  docs () {
    const destDir = path.join(projectRootDir, 'docs');
    const libDir = path.join(projectRootDir, 'lib');

    this.logger.log('Building Docs...');
    let markdown = docdown({
      'path':  path.join(libDir, 'bzTasksClass.js'),
      'title': `beelzebub - Task Class (v${version})`,
      'toc':   'categories',
      'url':   '../lib/bzTasks.js'
    });

    this.logger.log('Writng Docs...');
    fs.writeFile(path.join(destDir, 'taskClass.md'), buildUtils.injectExampleLinks(libDir, markdown));

    this.logger.log('-------------------------------------');
    markdown = docdown({
      'path':  path.join(libDir, 'bzInterfaceClass.js'),
      'title': `beelzebub - Task Class (v${version})`,
      'toc':   'categories',
      'url':   '../lib/bzTasks.js'
    });

    this.logger.log('Writing Docs...');
    fs.writeFile(path.join(destDir, 'interfaceClass.md'), buildUtils.injectExampleLinks(libDir, markdown));

    this.logger.log('-------------------------------------');
    this.logger.log('Done!');
  }
Exemplo n.º 2
0
each(sourceFiles, function(sourceFile) {
    var markdown = docdown({
        title: '',
        toc: 'categories',
        path: path.join(srcPath, sourceFile),
        url: 'https://github.com/helion3/inspire-tree/blob/master/src/' + sourceFile
    });

    var docName = sourceFile.split('/').pop().replace('.js', '.md');

    // Write file
    fs.writeFile(path.join(outPath, docName), markdown, function(err) {
        if (err) {
            console.log('Error writing to file:');
            console.log(err);
            return;
        }

        console.log('Wrote output for ' + sourceFile);
    });
});
Exemplo n.º 3
0
function build(type) {
  var options = _.defaults({}, config.base, config[type]),
      markdown = docdown(options);

  fs.writeFile(readmePath, postprocess(markdown), onComplete);
}
Exemplo n.º 4
0
    var stream = through(function (file, encoding, callback) {

        // clone options from args
        var options = JSON.parse(JSON.stringify(args));

        // get file path
        options.path = file.path;

        // reset url with path
        options.url = options.url.replace('{filePath}',path.relative(file.cwd,file.path));

        // reset title with path
        options.title = options.title.replace('{fileName}',path.relative(file.cwd,file.path));

        // doc it down
        var docDownContent = docdown(options);

        // pretty @example's content
        var exampleBlocks = docDownContent.match(/```js[.\s\S]*?```/gm);
        if(exampleBlocks){
            for(var i = 0; i < exampleBlocks.length; i++) {
                var examplesBlockItem = exampleBlocks[i],
                    lineArray = examplesBlockItem.split('\n'),
                    endLineContent = lineArray[lineArray.length-2]
                    ;
                // get beginningTab content
                var lineBeginningTab = endLineContent.match(/^[\s]*/g);

                if(lineBeginningTab){
                    // replace beginningTab to empty
                    var replaceRegx = new RegExp('\n' + lineBeginningTab[0],'g'),
                        pretttyExampleContent = examplesBlockItem.replace(replaceRegx,'\n')
                        ;
                    docDownContent = docDownContent.replace(examplesBlockItem,pretttyExampleContent);
                }
            }
        }

        // for output html
        if(options.outputType == 'html'){
            // covert to html
            var Showdown = require('showdown'),
                converter = new Showdown.converter(),
                htmlContent = converter.makeHtml(docDownContent)
                // back to div
                   .replace(/\<\!--\ \/div\ --\>/g,'</div>')
                   .replace(/\<\!--\ div\ --\>/g,'<div>')
                   .replace(/\<\!--\ div class="toc-container"\ --\>/g,'<div class="toc-container">')
                   .replace(/\<\!--\ div class="doc-container"\ --\>/g,'<div class="doc-container">')
                    // with prism.js highlight
                   .replace(/class="js"/g,'class="js language-javascript"')
                ;

            // ejs render
            var ejs = require('ejs');
            docDownContent = ejs.render(htmlTpl, {
                title : options.title,
                htmlContent : htmlContent
            });
        }

        // set buffer
        file.contents = new Buffer(docDownContent);

        // output file
        this.push(file);

        callback();
    }, function (callback) {
Exemplo n.º 5
0
/*----------------------------------------------------------------------------*/

/**
 * Creates the documentation markdown formatted for 'github' or 'site'.
 *
 * @private
 * @param {string} type The format type.
 */
function build(type) {
  const options = _.defaults({}, config.base, config[type]);
  const markdown = docdown(options);

  fs.writeFile(readmePath, postprocess(markdown), util.pitch);
}