How to use the @microsoft/api-extractor.ApiItemKind.Package 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 shlomiassaf / ngrid / tools / ng-packagr.transformers / api-docs / transformation / transformers / package.ts View on Github external
import { m, MdTypeMap } from '../../mdast';
import { ApiItemKind, ApiPackage, ApiItem } from '@microsoft/api-extractor';

import { ApiItemTransformer, BaseApiItemTransformer } from '../base';

@ApiItemTransformer({
  kind: ApiItemKind.Package,
  create: (apiItem: ApiPackage) => new ApiPackageTransformer(apiItem, 'root', true),
})
export class ApiPackageTransformer extends BaseApiItemTransformer<'root', ApiPackage> {
  mdast(): MdTypeMap['root'] {
    const apiMembers: ReadonlyArray = this.apiItem.entryPoints[0].members;
    const sections = {} as any;

    for (const apiMember of apiMembers) {
      try {
        this.context.add(apiMember);
      } catch (err) {
        console.warn(err.message);
        continue;
      }

      const arr = sections[apiMember.kind] || (sections[apiMember.kind] = [ m('heading', { depth: 2 }, [ m('text', { value: apiMember.kind }) ]) ]);