$process()

in tools/dgeni/processors/entry-point-grouper.ts [96:173]


  $process(docs: DocCollection) {
    const entryPoints = new Map<string, EntryPointDoc>();

    docs.forEach(doc => {
      const moduleInfo = this._getModulePackageInfo(doc);

      const packageName = moduleInfo.packageName;
      const packageDisplayName = packageName === 'cdk' ? 'CDK' : 'Material';

      const moduleImportPath = `@angular/${packageName}/${moduleInfo.entryPointName}`;
      const entryPointName = packageName + '-' + moduleInfo.name;

      // Compute a public URL that refers to the document. This is helpful if we want to
      // make references to other API documents. e.g. showing the extended class.
      doc.publicUrl = computeApiDocumentUrl(doc, moduleInfo);

      // Get the entry-point for this doc, or, if one does not exist, create it.
      let entryPoint;
      if (entryPoints.has(entryPointName)) {
        entryPoint = entryPoints.get(entryPointName)!;
      } else {
        entryPoint = new EntryPointDoc(entryPointName);
        entryPoints.set(entryPointName, entryPoint);
      }

      entryPoint.displayName = moduleInfo.name;
      entryPoint.moduleImportPath = moduleImportPath;
      entryPoint.packageName = packageName;
      entryPoint.packageDisplayName = packageDisplayName;

      // Put this doc into the appropriate list in the entry-point doc.
      if (doc.isDirective) {
        entryPoint.directives.push(doc);
      } else if (doc.isService) {
        entryPoint.services.push(doc);
      } else if (doc.isNgModule) {
        entryPoint.exportedNgModules.push(doc);
      } else if (doc.docType === 'class') {
        entryPoint.classes.push(doc);
        if (doc.isTestHarness) {
          entryPoint.testHarnesses.push(doc);
        }
      } else if (doc.docType === 'interface') {
        entryPoint.interfaces.push(doc);
      } else if (doc.docType === 'type-alias') {
        entryPoint.typeAliases.push(doc);
      } else if (doc.docType === 'function') {
        entryPoint.functions.push(doc);
      } else if (doc.docType === 'const') {
        entryPoint.constants.push(doc);
      }

      if (isPrimaryExportDoc(doc)) {
        entryPoint.primaryExportName = doc.name;
      }
    });

    // For each entry-point where no explicit primary export has been specified
    // through the "@docs-primary-export" tag, we determine a primary export by
    // looking for possible "NgModule" classes or test harnesses.
    entryPoints.forEach(entryPoint => {
      if (entryPoint.primaryExportName !== null) {
        return;
      }

      const ngModuleExport = this._findBestPrimaryExport(entryPoint.exportedNgModules);
      if (ngModuleExport !== null) {
        entryPoint.primaryExportName = ngModuleExport.name;
        return;
      }
      const testHarnessExport = this._findBestPrimaryExport(entryPoint.testHarnesses);
      if (testHarnessExport !== null) {
        entryPoint.primaryExportName = testHarnessExport.name;
      }
    });

    return Array.from(entryPoints.values());
  }