export function writeManifestAndTemplate()

in build-scripts/build_api_helpers.ts [159:194]


export function writeManifestAndTemplate(
    docsFolder: string, versionedDocsFolder: string, manifest: Manifest,
    docsVersion: string, templateFolder: string) {
  // Write docs manifest.
  fs.writeFileSync(
      `${versionedDocsFolder}/docs_manifest.json`,
      JSON.stringify(manifest, null, 2));

  // Load api docs manifest
  // If the docs version we just generated is not present, generate a new
  // hexo page for that version and add it to the versions.
  const apiManifestPath = `${docsFolder}/api_manifest.json`;
  const apiManifest =
      JSON.parse(fs.readFileSync(apiManifestPath, {encoding: 'utf8'}));

  if (!apiManifest.versions.includes(docsVersion)) {
    const newApiPagePath = `${templateFolder}/${docsVersion}/index.md`;
    console.log(
        'writeTemplate', docsVersion, newApiPagePath, docsFolder,
        versionedDocsFolder)
    writeTemplate(docsVersion, 'api', newApiPagePath)

    // We do not add 'local' to the api manifest, this prevents it from
    // showing up in the dropdown menu.
    if (docsVersion !== 'local') {
      apiManifest.versions.unshift(docsVersion);
      apiManifest.versions.sort(comparePackageVersions).reverse();
      fs.writeFileSync(apiManifestPath, JSON.stringify(apiManifest, null, 2));


      // Update the template for 'latest'.
      const newApiPagePath = `${templateFolder}/latest/index.md`;
      writeTemplate(apiManifest.versions[0], 'api', newApiPagePath);
    }
  }
}