How to use the @microsoft/api-extractor/lib/generators/ExcerptBuilder.ExcerptBuilder.build function in @microsoft/api-extractor

To help you get started, we’ve selected a few @microsoft/api-extractor examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github esfx / esfx / scripts / docs / patchApiExtractor.js View on Github external
ApiModelGenerator.prototype._processApiTypeAlias = function(astDeclaration, exportedName, parentApiItem) {
    console.log("ApiModelGenerator.prototype._processApiTypeAlias");
    const name = !!exportedName ? exportedName : astDeclaration.astSymbol.localName;
    const canonicalReference = ApiTypeAlias.getCanonicalReference(name);

    let apiTypeAlias = /** @type {ApiTypeAlias?} */(parentApiItem.tryGetMember(canonicalReference));
    if (apiTypeAlias === undefined) {
      const typeAliasDeclaration = /** @type {ts.TypeAliasDeclaration} */(astDeclaration.declaration);
      const nodesToCapture = [];
      // @ts-ignore
      const aliasTypeTokenRange = ExcerptBuilder.createEmptyTokenRange();
      nodesToCapture.push({ node: typeAliasDeclaration.type, tokenRange: aliasTypeTokenRange });

      const excerptTokens = ExcerptBuilder.build({
        startingNode: astDeclaration.declaration,
        nodesToCapture
      });
      // @ts-ignore
      const docComment = this._collector.fetchMetadata(astDeclaration).tsdocComment;
      // @ts-ignore
      const releaseTag = this._collector.fetchMetadata(astDeclaration.astSymbol).releaseTag;
      // @ts-ignore
      apiTypeAlias = new ApiTypeAlias({ name, docComment, releaseTag, excerptTokens, aliasTypeTokenRange });
      parentApiItem.addMember(apiTypeAlias);
    }
};