How to use @microsoft/api-extractor-model - 10 common examples

To help you get started, we’ve selected a few @microsoft/api-extractor-model 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 microsoft / rushstack / apps / api-documenter / src / cli / BaseAction.ts View on Github external
console.log(colors.yellow(`Warning: Unresolved @inheritDoc tag for ${apiItem.displayName}: `
              + result.errorMessage));
          } else {
            if (result.resolvedApiItem instanceof ApiDocumentedItem
              && result.resolvedApiItem.tsdocComment
              && result.resolvedApiItem !== apiItem) {
              this._copyInheritedDocs(apiItem.tsdocComment, result.resolvedApiItem.tsdocComment);
            }
          }
        }

      }
    }

    // Recurse members
    if (ApiItemContainerMixin.isBaseClassOf(apiItem)) {
      for (const member of apiItem.members) {
        this._applyInheritDoc(member, apiModel);
      }
    }
  }
github OfficeDev / office-ui-fabric-react / packages / api-docs / src / generatePageJsonFiles.ts View on Github external
export function generatePageJsonFiles(options: IPageJsonOptions): void {
  const { pageGroups = {}, fallbackGroup, outputRoot, apiJsonPaths, min } = options;

  // Create and/or empty output folders
  fse.emptyDirSync(outputRoot);
  for (const group of Object.keys(pageGroups)) {
    fse.emptyDirSync(path.join(outputRoot, group));
  }
  if (fallbackGroup) {
    fse.emptyDirSync(path.join(outputRoot, fallbackGroup));
  }

  // Load api-extractor output from packages into a model
  const apiModel = new ApiModel();
  for (const apiJsonPath of apiJsonPaths) {
    console.log('Loading ' + apiJsonPath);
    apiModel.loadPackage(apiJsonPath);
  }

  // Generate the page data
  const pageJsonByName = generatePageJson(apiModel, pageGroups, fallbackGroup);

  // Warn if any requested page names didn't correspond to a docCategory found in the API info
  const requestedPages = ([] as string[]).concat(...Object.values(pageGroups));
  for (const pageName of requestedPages) {
    if (!pageJsonByName.has(pageName)) {
      console.warn('Warning: no API items found for expected @docCategory ' + pageName);
    }
  }
github OfficeDev / office-ui-fabric-react / packages / api-docs / src / PageJsonGenerator.tsx View on Github external
// collect page data
    // Create the folder if it doesn't already exist
    FileSystem.ensureFolder(option.pageJsonFolderPath);

    console.log('Deleting contents of ' + option.pageJsonFolderPath);
    FileSystem.ensureEmptyFolder(option.pageJsonFolderPath);

    // Store the data for each page in a map
    for (const pageName of option.pageNames) {
      collectedData.pageDataByPageName.set(pageName, new PageData(pageName, option.kind));
    }

    for (const apiJsonPath of option.apiJsonPaths) {
      console.log('Loading ' + apiJsonPath);

      const apiModel: ApiModel = new ApiModel();
      // NOTE: later you can load other packages into the model and process them together
      const apiPackage: ApiPackage = apiModel.loadPackage(apiJsonPath);

      console.log('Successfully loaded ' + apiJsonPath);

      const apiEntryPoint: ApiEntryPoint = apiPackage.entryPoints[0]; // assume there is only one entry point

      collectPageData(collectedData, apiEntryPoint, option.kind);
    }
  }

  // create files
  for (const option of options) {
    createPageJsonFiles(collectedData, option);
  }
}
github ifiokjr / remirror / @remirror / api-documenter / src / documenters / markdown-documenter.ts View on Github external
const scopedName: string = apiItem.getScopedNameWithinPackage();
    // console.log(scopedName);

    switch (apiItem.kind) {
      case ApiItemKind.Class:
        output.appendNode(new DocHeading({ configuration, title: `${scopedName} class` }));
        break;
      case ApiItemKind.Enum:
        output.appendNode(new DocHeading({ configuration, title: `${scopedName} enum` }));
        break;
      case ApiItemKind.Interface:
        output.appendNode(new DocHeading({ configuration, title: `${scopedName} interface` }));
        break;
      case ApiItemKind.Method:
      case ApiItemKind.MethodSignature:
        output.appendNode(new DocHeading({ configuration, title: `${scopedName} method` }));
        break;
      case ApiItemKind.Function:
        output.appendNode(new DocHeading({ configuration, title: `${scopedName} function` }));
        break;
      case ApiItemKind.Namespace:
        output.appendNode(new DocHeading({ configuration, title: `${scopedName} namespace` }));
        break;
      case ApiItemKind.Package:
        const unscopedPackageName: string = PackageName.getUnscopedName(apiItem.displayName);
        console.log(apiItem.displayName);
        output.appendNode(new DocHeading({ configuration, title: `${unscopedPackageName} package` }));
        break;
      case ApiItemKind.Property:
      case ApiItemKind.PropertySignature:
        output.appendNode(new DocHeading({ configuration, title: `${scopedName} property` }));
github esfx / esfx / scripts / docs / yamlDocumenter.js View on Github external
const remarks = this._renderMarkdown(tsdocComment.remarksBlock.content, apiItem);
                if (remarks) {
                    yamlItem.remarks = remarks;
                }
            }

            if (tsdocComment.deprecatedBlock) {
                // @ts-ignore
                const deprecatedMessage = this._renderMarkdown(tsdocComment.deprecatedBlock.content, apiItem);
                if (deprecatedMessage.length > 0) {
                    yamlItem.deprecated = { content: deprecatedMessage };
                }
            }
        }

        if (ApiReleaseTagMixin.isBaseClassOf(apiItem)) {
            if (apiItem.releaseTag === 3) {
                yamlItem.isPreview = true;
            }
        }

        yamlItem.name = this._getYamlItemName(apiItem);
        yamlItem.fullName = yamlItem.name;
        yamlItem.langs = ['typeScript'];

        switch (apiItem.kind) {
            case "Enum":
                yamlItem.type = 'enum';
                break;
            case "EnumMember":
                yamlItem.type = 'field';
                const enumMember = /** @type {ApiEnumMember} */(apiItem);
github microsoft / rushstack / apps / api-documenter / src / documenters / YamlDocumenter.ts View on Github external
}

          if (this._apiItemsByTypeName.has(typeName)) {
            // We saw this name before, so it's an ambiguous match
            ambiguousNames.add(typeName);
            break;
          }

          this._apiItemsByTypeName.set(typeName, apiItem);
        }

        break;
    }

    // Recurse container members
    if (ApiItemContainerMixin.isBaseClassOf(apiItem)) {
      for (const apiMember of apiItem.members) {
        this._initApiItemsByTypeNameRecursive(apiMember, ambiguousNames);
      }
    }
  }
github esfx / esfx / scripts / docs.js View on Github external
}
        }
    }

    if (apiItem.displayName === "__computed" && apiItem instanceof ApiDeclaredItem) {
        const match = /\[[^\[\]]+\]/.exec(apiItem.excerpt.text);
        if (match) {
            const nameSymbol = getNameSymbol(apiItem);
            if (nameSymbol) {
                apiItem[nameSymbol] = match[0];
            }
        }
    }

    // Recurse members
    if (ApiItemContainerMixin.isBaseClassOf(apiItem)) {
        for (const member of apiItem.members) {
            fixupModel(member, apiModel);
        }
    }
}
github esfx / esfx / scripts / docs / yamlDocumenter.js View on Github external
// @ts-ignore
                    if (this._apiItemsByTypeName.has(typeName)) {
                        // We saw this name before, so it's an ambiguous match
                        ambiguousNames.add(typeName);
                        break;
                    }

                    // @ts-ignore
                    this._apiItemsByTypeName.set(typeName, apiItem);
                }

                break;
        }

        // Recurse container members
        if (ApiItemContainerMixin.isBaseClassOf(apiItem)) {
            for (const apiMember of apiItem.members) {
                this._initApiItemsByTypeNameRecursive(apiMember, ambiguousNames);
            }
        }
    }
github esfx / esfx / scripts / docs / yamlDocumenter.js View on Github external
[kGetSafeName](apiItem) {
        let safeName = this[kSafeNames].get(apiItem);
        if (!safeName) {
            safeName = apiItem.displayName;
            if (safeName === ts.InternalSymbolName.Computed && apiItem instanceof ApiDeclaredItem) {
                const match = /\[[^\[\]]+\]/.exec(apiItem.excerpt.text);
                if (match) {
                    safeName = match[0];
                }
            }
            if (this[kCollidesWithItemsOfSameName](apiItem)) {
                safeName += `_${apiItem.kind}`;
            }
            // For overloaded methods, add a suffix such as "MyClass.myMethod_2".
            if (ApiParameterListMixin.isBaseClassOf(apiItem)) {
                if (apiItem.overloadIndex > 0) {
                    safeName += `_${apiItem.overloadIndex}`;
                }
            }
            this[kSafeNames].set(apiItem, safeName);
        }
        return safeName;
    }
github microsoft / rushstack / apps / api-documenter / src / documenters / YamlDocumenter.ts View on Github external
protected _getUid(apiItem: ApiItem): string {
    let result: string = '';
    for (const hierarchyItem of apiItem.getHierarchy()) {
      // For overloaded methods, add a suffix such as "MyClass.myMethod_2".
      let qualifiedName: string = hierarchyItem.displayName;
      if (ApiParameterListMixin.isBaseClassOf(hierarchyItem)) {
        if (hierarchyItem.overloadIndex > 1) {
          // Subtract one for compatibility with earlier releases of API Documenter.
          // (This will get revamped when we fix GitHub issue #1308)
          qualifiedName += `_${hierarchyItem.overloadIndex - 1}`;
        }
      }

      switch (hierarchyItem.kind) {
        case ApiItemKind.Model:
        case ApiItemKind.EntryPoint:
          break;
        case ApiItemKind.Package:
          result += PackageName.getUnscopedName(hierarchyItem.displayName);
          break;
        default:
          result += '.';