Skip to content

Commit 34c503c

Browse files
authored
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
1 parent f32cc8f commit 34c503c

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

scripts/docgen-compat/generate-docs.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,24 @@ function fixAllLinks(htmlFiles) {
281281
return Promise.all(writePromises);
282282
}
283283

284+
const PROJECT_FILE_PATH = {
285+
'js': '/docs/reference/js/v8/_project.yaml',
286+
'node': '/docs/reference/node/_project.yaml'
287+
};
288+
async function setProjectYamlPath(api) {
289+
const defaultTemplatePath = path.resolve(
290+
`${__dirname}/theme/layouts/default.hbs`
291+
);
292+
const defaultTemplateText = await fs.readFile(defaultTemplatePath, 'utf8');
293+
const projectFilePath = PROJECT_FILE_PATH[api];
294+
console.log('replacing', projectFilePath);
295+
const replacedText = defaultTemplateText.replace(
296+
/(<meta name="project_path" value=")[a-zA-Z0-9\/_\.]+(" \/>)/,
297+
`$1${projectFilePath}$2`
298+
);
299+
await fs.writeFile(defaultTemplatePath, replacedText);
300+
}
301+
284302
/**
285303
* Generate an temporary abridged version of index.d.ts used to create
286304
* Node docs.
@@ -357,6 +375,9 @@ Promise.all([
357375
return generateNodeSource();
358376
}
359377
})
378+
.then(() => {
379+
setProjectYamlPath(apiType);
380+
})
360381
// Run main Typedoc process (uses index.d.ts and generated temp file above).
361382
.then(runTypedoc)
362383
.then(async output => {

scripts/docgen-compat/theme/layouts/default.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<meta charset="utf-8">
55
<meta http-equiv="X-UA-Compatible" content="IE=edge">
66
<meta name="hide_page_heading" value="true" />
7-
<meta name="project_path" value="/docs/reference/js/_project.yaml" />
7+
<meta name="project_path" value="/docs/reference/node/_project.yaml" />
88
<meta name="book_path" value="/docs/reference/_book.yaml" />
99
<meta name="translation" value="disabled" />
1010
<meta name="page_type" value="reference" />

0 commit comments

Comments
 (0)