Code coverage report for lib/helpers.js

Statements: 13.95% (6 / 43)      Branches: 0% (0 / 16)      Functions: 0% (0 / 7)      Lines: 13.95% (6 / 43)      Ignored: none     

All files » lib/ » helpers.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94                1             1                               1           1                                           1                                 1                                  
 
/**
 * The helpers module
 *
 * @module helpers
 * @main helpers
 */
 
const _ = require('underscore');
 
/**
 * Build file tree
 * @method renderFileTree
 */
// TODO(Yorkie): remove the buildFileTree
exports.buildFileTree = function onbuildFileTree (items) {
  var out = '<ul>';
  _.each(items, function (i, k) {
    out += '<li>';
    if (_.isObject(i)) {
      if (!i.path) {
        out += k + '/' + onbuildFileTree(i);
      } else {
        out += '<a href="../files/' + i.name + '.html">' + k + '</a>';
      }
    }
    out += '</li>';
  });
  out += '</ul>';
  return out;
};
exports.renderFileTree = exports.buildFileTree;
 
/**
 * Create cross link
 * @method crossLink
 */
exports.crossLink = function oncrossLink (item, options) {
  var str = '';
  if (!item) {
    item = '';
  }
  if (item.indexOf('|') > 0) {
    var parts = item.split('|'),
      p = [];
    _.each(parts, function (i) {
      p.push(this._parseCrossLink.call(this, i));
    }, this);
    str = p.join(' | ');
  } else {
    str = this._parseCrossLink.call(this, item, false, options.fn(this));
  }
  return str;
};
 
/**
 * Create cross link module
 * @method crossLinkModule
 */
exports.crossLinkModule = function oncrossLinkModule (item, options) {
  var str = item;
  if (this.ast.modules[item]) {
    var content = options.fn(this);
    if (content === "") {
      content = item;
    }
    str = '<a href="../modules/' + item.replace(/\//g, '_') +
          '.html">' + content + '</a>';
  }
  return str;
};
 
/**
 * Create cross link to raw
 * @method crossLinkRaw
 */
exports.crossLinkRaw = function oncrossLinkRaw (item, options) {
  var str = '';
  if (!item) {
    item = '';
  }
  if (item.indexOf('|') > 0) {
    var parts = item.split('|'),
      p = [];
    _.each(parts, function (i) {
      p.push(this._parseCrossLink.call(this, i, true));
    }, this);
    str = p.join(' | ');
  } else {
    str = this._parseCrossLink.call(this, item, true);
  }
  return str;
};