scripts/generate-demo-app-docs.js
function generateComponent(typedocHtmlFile, relativeTypedocHtmlFile, demoAppDocsModuleDir) {
  const directory = path.dirname(relativeTypedocHtmlFile);
  mkdirp.sync(path.join(demoAppDocsModuleDir, directory));

  const fileName = path.basename(relativeTypedocHtmlFile);
  const componentHtmlFileName = fileName.replace(/\.html$/, '.component.html');

  const componentHtmlFile = path.join(demoAppDocsModuleDir, directory, componentHtmlFileName);
  const typedocHtmlFileContent = fs.readFileSync(typedocHtmlFile, { encoding: 'utf8' });
  const escapedHtmlFileContent = fixRouterFragments(fixReadmeMdLinks(escapeHtmlForAngular(typedocHtmlFileContent)));

  fs.writeFileSync(componentHtmlFile, escapedHtmlFileContent, { encoding: 'utf8' });

  const componentFileName = fileName.replace(/\.html$/, '.component');
  const componentTsFileName = componentFileName + '.ts';
  const componentTsFile = path.join(demoAppDocsModuleDir, directory, componentTsFileName);

  const componentName = generateComponentName(fileName);
  const componentTsFileContent = `import { Component } from '@angular/core';

@Component({
  templateUrl: './${componentHtmlFileName}'
})
export class ${componentName} { }
`;
  fs.writeFileSync(componentTsFile, componentTsFileContent, { encoding: 'utf8' });

  // Return metadata for generating module file
  return {
    name: componentName,
    file: path.join(directory, componentFileName),
    route: relativeTypedocHtmlFile // route is based on original file name
  };
}
function generateComponent(typedocHtmlFile, relativeTypedocHtmlFile, demoAppDocsModuleDir) {
  const directory = path.dirname(relativeTypedocHtmlFile);
  mkdirp.sync(path.join(demoAppDocsModuleDir, directory));

  const fileName = path.basename(relativeTypedocHtmlFile);
  const componentHtmlFileName = fileName.replace(/\.html$/, '.component.html');

  const componentHtmlFile = path.join(demoAppDocsModuleDir, directory, componentHtmlFileName);
  const typedocHtmlFileContent = fs.readFileSync(typedocHtmlFile, { encoding: 'utf8' });
  const escapedHtmlFileContent = fixRouterFragments(fixReadmeMdLinks(escapeHtmlForAngular(typedocHtmlFileContent)));

  fs.writeFileSync(componentHtmlFile, escapedHtmlFileContent, { encoding: 'utf8' });

  const componentFileName = fileName.replace(/\.html$/, '.component');
  const componentTsFileName = componentFileName + '.ts';
  const componentTsFile = path.join(demoAppDocsModuleDir, directory, componentTsFileName);

  const componentName = generateComponentName(fileName);
  const componentTsFileContent = `import { Component } from '@angular/core';

@Component({
  templateUrl: './${componentHtmlFileName}'
})
export class ${componentName} { }
`;
  fs.writeFileSync(componentTsFile, componentTsFileContent, { encoding: 'utf8' });

  // Return metadata for generating module file
  return {
    name: componentName,
    file: path.join(directory, componentFileName),
    route: relativeTypedocHtmlFile // route is based on original file name
  };
}
Convert typedoc HTML file into Angular component for use in demo app