Code coverage report for lib/parsers/polyglot.js

Statements: 100% (6 / 6)      Branches: 100% (0 / 0)      Functions: 100% (2 / 2)      Lines: 100% (6 / 6)      Ignored: none     

All files » lib/parsers/ » polyglot.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    26                       26 1     1       1       26  
'use strict';
 
var getComments = require('get-comments'),
  extend = require('extend'),
  isJSDocComment = require('../../lib/is_jsdoc_comment'),
  parse = require('../../lib/parse');
 
/**
 * Documentation stream parser: this receives a module-dep item,
 * reads the file, parses the JavaScript, parses the JSDoc, and
 * emits parsed comments.
 * @param {Object} data a chunk of data provided by module-deps
 * @return {Array<Object>} adds to memo
 */
function parsePolyglot(data) {
  return getComments(data.source, true)
    .filter(isJSDocComment)
    .map(function (comment) {
      var context = {
        loc: extend({}, comment.loc),
        file: data.file
      };
      return parse(comment.value, comment.loc, context);
    });
}
 
module.exports = parsePolyglot;