mirror of
https://github.com/documentationjs/documentation.git
synced 2026-01-25 14:26:29 +00:00
28 lines
774 B
JavaScript
28 lines
774 B
JavaScript
'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;
|