function createShredExamplePackage()

in tools/doc-shredder/doc-shredder.js [104:152]


function createShredExamplePackage(shredOptions) {
  var pkg = new Dgeni.Package('doc-shredder', [
    // require('dgeni-packages/base') - doesn't work
  ]);
  var options = resolveShredOptions(shredOptions);

  initializePackage(pkg)
    .factory(require('./fileReaders/regionFileReader'))
    .processor(require('./processors/renderAsMarkdownProcessor'))
    .config(function(readFilesProcessor, regionFileReader) {
      readFilesProcessor.fileReaders = [regionFileReader];
    })
    // default configs - may be overridden
    .config(function(log, readFilesProcessor) {
      log.level = _getLogLevel(shredOptions);
      // Specify the base path used when resolving relative paths to source and output files
      readFilesProcessor.basePath = "/";

      // Specify collections of source files that should contain the documentation to extract
      var extns = ['*.ts', '*.html', '*.js', '*.css', '*.json', '*.dart', '*.yaml', '*.es6' ];
      var includeFiles = extns.map(function(extn) {
        if (options.includeSubdirs) {
          return path.join(options.examplesDir, '**', extn);
        } else {
          return path.join(options.examplesDir, extn);
        }
      });

      // HACK ( next two lines) because the glob function that dgeni uses internally isn't good at removing 'node_modules' early
      // this just uses globby to 'preglob' the include files ( and  exclude the node_modules).
      var includeFiles = globby.sync( includeFiles, { ignore: ignoreDirs } );

      log.info(`Shredding ${includeFiles.length} files inside ${shredOptions.examplesDir}`);

      readFilesProcessor.sourceFiles = [ {
        // Process all candidate files in `src` and its subfolders ...
        include: includeFiles ,
        exclude: [ '**/node_modules/**', '**/dist/**', '**/dart/build/**'],
        // When calculating the relative path to these files use this as the base path.
        // So `src/foo/bar.js` will have relative path of `foo/bar.js`
        basePath: options.examplesDir
      } ];
    })
    .config(function(writeFilesProcessor) {
      // Specify where the writeFilesProcessor will write our generated doc files
      writeFilesProcessor.outputFolder  = path.resolve(options.fragmentsDir);
    });
  return pkg;
}