From 34c503c35922be44ff820fcfa94c99005f5af618 Mon Sep 17 00:00:00 2001 From: Christina Holland Date: Tue, 26 Jul 2022 09:42:07 -0700 Subject: [PATCH] Generate v8 docs with correct project paths (#6475) * Generate v8 docs with correct project paths * Make sure to add numbers to regex * Remove extra file --- scripts/docgen-compat/generate-docs.js | 21 +++++++++++++++++++ .../docgen-compat/theme/layouts/default.hbs | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/scripts/docgen-compat/generate-docs.js b/scripts/docgen-compat/generate-docs.js index d02672c6cd1..0aed77640f7 100644 --- a/scripts/docgen-compat/generate-docs.js +++ b/scripts/docgen-compat/generate-docs.js @@ -281,6 +281,24 @@ function fixAllLinks(htmlFiles) { return Promise.all(writePromises); } +const PROJECT_FILE_PATH = { + 'js': '/docs/reference/js/v8/_project.yaml', + 'node': '/docs/reference/node/_project.yaml' +}; +async function setProjectYamlPath(api) { + const defaultTemplatePath = path.resolve( + `${__dirname}/theme/layouts/default.hbs` + ); + const defaultTemplateText = await fs.readFile(defaultTemplatePath, 'utf8'); + const projectFilePath = PROJECT_FILE_PATH[api]; + console.log('replacing', projectFilePath); + const replacedText = defaultTemplateText.replace( + /()/, + `$1${projectFilePath}$2` + ); + await fs.writeFile(defaultTemplatePath, replacedText); +} + /** * Generate an temporary abridged version of index.d.ts used to create * Node docs. @@ -357,6 +375,9 @@ Promise.all([ return generateNodeSource(); } }) + .then(() => { + setProjectYamlPath(apiType); + }) // Run main Typedoc process (uses index.d.ts and generated temp file above). .then(runTypedoc) .then(async output => { diff --git a/scripts/docgen-compat/theme/layouts/default.hbs b/scripts/docgen-compat/theme/layouts/default.hbs index 904e18cbcae..d2d327c10b2 100644 --- a/scripts/docgen-compat/theme/layouts/default.hbs +++ b/scripts/docgen-compat/theme/layouts/default.hbs @@ -4,7 +4,7 @@ - +