How to use the @microsoft/api-extractor.Extractor 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 Azure / azure-sdk-for-js / sdk / cosmosdb / cosmos / bundle-types.js View on Github external
// TODO. The api-extractor CLI command forces us into their docs generation and will error.
// By invoking the node API we avoid this.
// But we also swallow errors.
// See https://github.com/Microsoft/web-build-tools/issues/920
const ApiExtractor = require("@microsoft/api-extractor");
const NodeCoreLib = require("@microsoft/node-core-library");
const config = NodeCoreLib.JsonFile.loadAndValidate(
  "api-extractor.json",
  ApiExtractor.Extractor.jsonSchema
);

// This interface provides additional runtime state that is NOT part of the config file
const options = {
  localBuild: process.argv.indexOf("--ship") < 0
};
const extractor = new ApiExtractor.Extractor(config, options);
extractor.processProject();
github OfficeDev / office-ui-fabric-react / scripts / api-extractor.js View on Github external
validationRules: {
    missingReleaseTags: 'allow'
  }
};

// This interface provides additional runtime state
// that is NOT part of the config file
const options = {
  // Indicates that API Extractor is running as part of a local build,
  // e.g. on developer's machine. For example, if the *.api.ts output file
  // has differences, it will be automatically overwritten for a
  // local build, whereas this should report an error for a production build.
  localBuild: process.argv.indexOf('--ship') < 0
};

const extractor = new Extractor(config, options);
extractor.analyzeProject();
github OfficeDev / office-ui-fabric-react / scripts / tasks / api-extractor.js View on Github external
},
    project: {
      entryPointSourceFile: 'lib/index.d.ts'
    },
    validationRules: {
      missingReleaseTags: 'allow'
    }
  };

  // This interface provides additional runtime state
  // that is NOT part of the config file
  const extractorOptions = {
    localBuild: options.args && options.args.indexOf('--local') >= 0
  };

  const extractor = new Extractor(config, extractorOptions);
  const success = extractor.processProject();
  if (!success) {
    throw 'The public API file is out of date. Please run "npm run update-api" and commit the updated API file.';
  }
};
github microsoft / rushstack / stack / rush-stack-compiler-3.1 / src / ApiExtractorRunner.ts View on Github external
public invoke(): Promise {
    try {
      const extractorOptions: IExtractorOptions = {
        ...this._extractorOptions,
        customLogger: {
          logVerbose: this._terminal.writeVerboseLine.bind(this._terminal),
          logInfo: this._terminal.writeLine.bind(this._terminal),
          logWarning: this._terminal.writeWarningLine.bind(this._terminal),
          logError: this._terminal.writeErrorLine.bind(this._terminal)
        },
        typescriptCompilerFolder: ToolPaths.typescriptPackagePath
      };

      const extractor: Extractor = new Extractor(this._extractorConfig, extractorOptions);

      // NOTE: processProject() returns false if errors or warnings occurred, however we
      // already handle this above via our customLogger
      extractor.processProject();

      return Promise.resolve();
    } catch (e) {
      return Promise.reject(e);
    }
  }
}
github microsoft / rushstack / core-build / gulp-core-build-typescript / src / ApiExtractorTask.ts View on Github external
publishFolderForBeta: this.taskConfig.publishFolderForBeta,
          publishFolderForPublic: this.taskConfig.publishFolderForPublic
        };
      }

      const extractorOptions: IExtractorOptions = {
        localBuild: !this.buildConfig.production,
        customLogger: {
          logVerbose: (message: string) => this.logVerbose(message),
          logInfo: (message: string) => this.log(message),
          logWarning: (message: string) => this.logWarning(message),
          logError: (message: string) => this.logError(message)
        }
      };

      const extractor: Extractor = new Extractor(extractorConfig, extractorOptions);

      // NOTE: processProject() returns false if errors or warnings occurred, however we
      // already handle this above via our customLogger
      extractor.processProject();
    } catch (e) {
      completeCallback(e.message);
      return;
    }

    completeCallback();
  }
github SimplrJS / ts-docs-gen / src / extractor / api-extractor.ts View on Github external
constructor(private compilerOptions: ts.CompilerOptions, apiErrorHandler?: ApiErrorHandler) {
        /**
         * We need to ignore @types in these tests
         * @see https://github.com/Microsoft/web-build-tools/wiki/API-Extractor-~-Enabling-for-your-project
         */
        this.compilerOptions.typeRoots = ["./"];

        this.extractor = new Extractor({
            compilerOptions: this.compilerOptions,
            errorHandler: apiErrorHandler
        });
    }