export function serializeClass()

in build-scripts/doc-gen/parser.ts [298:362]


export function serializeClass(
    checker: ts.TypeChecker, node: ts.ClassDeclaration, docInfo: util.DocInfo,
    sourceFile: ts.SourceFile, docHeadings: DocHeading[], repoPath: string,
    srcRoot: string, githubRoot: string): DocClass {
  const symbol = checker.getSymbolAtLocation(node.name);
  const name = symbol.getName();

  // Parse inheritance clauses if they exist.
  let inheritsFrom = null;
  if (node.heritageClauses != null) {
    const extendsSymbols: string[] = [];
    node.heritageClauses.forEach(heritageClause => {
      heritageClause.types.forEach(type => {
        extendsSymbols.push(type.getText());
      });
    });
    inheritsFrom = extendsSymbols.join('|');
  }

  const {displayFilename, githubUrl} =
      util.getFileInfo(node, sourceFile, repoPath, srcRoot, githubRoot);

  let documentation =
      ts.displayPartsToString(symbol.getDocumentationComment(checker));
  documentation = util.removeStarsFromCommentString(documentation);
  const docClass: DocClass = {
    docInfo: docInfo,
    symbolName: name,
    namespace: docInfo.namespace,
    documentation,
    fileName: displayFilename,
    githubUrl,
    methods: [],
    isClass: true
  };
  if (inheritsFrom != null) {
    // Identifier generic map can be undefined here because we just want to
    // remove generics from the type.
    const identifierGenericMap = {};
    docClass.inheritsFrom = util.sanitizeTypeString(inheritsFrom, {});
  }

  // Parse the methods that are annotated with @doc.
  node.members.forEach(member => {
    if (ts.isMethodDeclaration(member) && !util.isStatic(member)) {
      const docInfo = util.getDocDecoratorOrAnnotation(
          checker, member, DOCUMENTATION_DECORATOR_AND_ANNOTATION);
      if (docInfo != null) {
        docClass.methods.push(serializeMethodOrFunction(
            checker, member, docInfo, sourceFile, repoPath, srcRoot,
            githubRoot));
      }
    }
  });

  // Fill in `extraTypes` if specified.
  const docExtraTypes =
      util.getDocDecoratorOrAnnotation(
          checker, node, DOCUMENTATION_EXTRA_TYPES) as {} as DocExtraType[];
  if (docExtraTypes != null) {
    docClass.extraTypes = docExtraTypes;
  }

  return docClass;
}