mirror of
https://github.com/documentationjs/documentation.git
synced 2026-01-18 14:17:30 +00:00
* Source-sorting by default Many changes * Uses a new version of module-deps that exposes a sort key we use to sort documentation. * Adds inference for methods in objects * Groups events into a separate comment property * Add jsdoc property. Refs https://github.com/documentationjs/documentation/pull/388#issuecomment-215791547 * Namespaces and paths * More powerful paths: paths now include name, kind, and scope * comments now include a 'namespace' property with a formatted namespace * Fix tests * Re-ignore fonts * Nix sourceKey from output * Pin dependency versions * Fix module-deps-sortable ref * Update tests for right deps
54 lines
1.5 KiB
JavaScript
54 lines
1.5 KiB
JavaScript
'use strict';
|
|
|
|
var mdeps = require('module-deps-sortable'),
|
|
fs = require('fs'),
|
|
path = require('path'),
|
|
babelify = require('babelify'),
|
|
concat = require('concat-stream'),
|
|
moduleFilters = require('../../lib/module_filters');
|
|
|
|
/**
|
|
* Returns a readable stream of dependencies, given an array of entry
|
|
* points and an object of options to provide to module-deps.
|
|
*
|
|
* This stream requires filesystem access, and thus isn't suitable
|
|
* for a browser environment.
|
|
*
|
|
* @param {Array<string>} indexes paths to entry files as strings
|
|
* @param {Object} options optional options passed
|
|
* @param {Function} callback called with (err, inputs)
|
|
* @returns {undefined} calls callback
|
|
*/
|
|
function dependencyStream(indexes, options, callback) {
|
|
var md = mdeps({
|
|
filter: function (id) {
|
|
return !!options.external || moduleFilters.internalOnly(id);
|
|
},
|
|
transform: [babelify.configure({
|
|
sourceMap: false,
|
|
presets: [
|
|
require('babel-preset-es2015'),
|
|
require('babel-preset-stage-0'),
|
|
require('babel-preset-react')
|
|
]
|
|
})],
|
|
postFilter: moduleFilters.externals(indexes, options)
|
|
});
|
|
indexes.forEach(function (index) {
|
|
md.write(path.resolve(index));
|
|
});
|
|
md.end();
|
|
md.once('error', function (error) {
|
|
return callback(error);
|
|
});
|
|
md.pipe(concat(function (inputs) {
|
|
callback(null, inputs.map(function (input) {
|
|
// un-transform babelify transformed source
|
|
input.source = fs.readFileSync(input.file, 'utf8');
|
|
return input;
|
|
}));
|
|
}));
|
|
}
|
|
|
|
module.exports = dependencyStream;
|