var createShredMapPackage = function()

in tools/doc-shredder/doc-shredder.js [207:292]


var createShredMapPackage = function(mapOptions) {
  var pkg = new Dgeni.Package('doc-shred-mapper', [
    require('dgeni-packages/base'),
    require('dgeni-packages/nunjucks')
  ]);
  var options = resolveMapOptions(mapOptions);

  initializePackage(pkg)
    .factory(require('./fileReaders/extractPathsReader'))
    .processor(require('./processors/shredMapProcessor'))
    .config(function(shredMapProcessor) {
      shredMapProcessor.options = options;
    })
    .config(function(log, readFilesProcessor, extractPathsReader ) {
      log.level = _getLogLevel(mapOptions);
      readFilesProcessor.fileReaders = [ extractPathsReader];
    })
    // default configs - may be overridden
    .config(function(readFilesProcessor) {
      // 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 = ['*.jade' ];
      var includeFiles = extns.map(function(extn) {
        if (options.includeSubdirs) {
          return path.join(options.jadeDir, '**', extn);
        } else {
          return path.join(options.jadeDir, 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 } );


      readFilesProcessor.sourceFiles = [ {
        // Process all candidate files in `src` and its subfolders ...
        include: includeFiles,
        exclude: ['**/node_modules/**', '**/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.jadeDir
      } ];
    })
    .config(function(writeFilesProcessor, renderDocsProcessor, unescapeCommentsProcessor) {
      if (!mapOptions.writeFilesEnabled) {
        // dgeni hack to allow a geni task to simply return the results of the shredMapProcessor directly
        renderDocsProcessor.$enabled = false;
        writeFilesProcessor.$enabled = false;
        unescapeCommentsProcessor.$enabled = false;
      } else {
        // Specify where the writeFilesProcessor will write our generated doc files
        writeFilesProcessor.outputFolder = path.resolve(options.outputDir);
      }
    })
    .config(function(templateFinder) {
      // look for templates in this folder
      templateFinder.templateFolders = [ path.resolve(__dirname) ];

      // Specify how to match docs to templates.
      // In this case we just use the same static template for all docs
      templateFinder.templatePatterns = [ '${ doc.docType }.template' ];
    })
    .config(function(computePathsProcessor, computeIdsProcessor)  {
      computePathsProcessor.$enabled = false;
      computeIdsProcessor.$enabled = false;
      // Unused for now.
      //computePathsProcessor.pathTemplates.push({
      //  docTypes: ['foo'],
      //  pathTemplate: '',
      //  getOutputPath: function () {
      //  },
      //});
      //
      //computeIdsProcessor.idTemplates.push({
      //  docTypes: ['foo'],
      //  getAliases: function (doc) {
      //    return [doc.id];
      //  }
      //});
    });

  return pkg;
}