Skip to content

Commit

Permalink
Generate v8 docs with correct project paths (#6475)
Browse files Browse the repository at this point in the history
* Generate v8 docs with correct project paths

* Make sure to add numbers to regex

* Remove extra file
  • Loading branch information
hsubox76 committed Jul 26, 2022
1 parent f32cc8f commit 34c503c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
21 changes: 21 additions & 0 deletions scripts/docgen-compat/generate-docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
/(<meta name="project_path" value=")[a-zA-Z0-9\/_\.]+(" \/>)/,
`$1${projectFilePath}$2`
);
await fs.writeFile(defaultTemplatePath, replacedText);
}

/**
* Generate an temporary abridged version of index.d.ts used to create
* Node docs.
Expand Down Expand Up @@ -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 => {
Expand Down
2 changes: 1 addition & 1 deletion scripts/docgen-compat/theme/layouts/default.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="hide_page_heading" value="true" />
<meta name="project_path" value="/docs/reference/js/_project.yaml" />
<meta name="project_path" value="/docs/reference/node/_project.yaml" />
<meta name="book_path" value="/docs/reference/_book.yaml" />
<meta name="translation" value="disabled" />
<meta name="page_type" value="reference" />
Expand Down

0 comments on commit 34c503c

Please sign in to comment.