Skip to content

Remove excluded packages from doc index.md #6651

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 6, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion scripts/docgen/docgen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,12 @@ async function generateDocs(

await moveRulesUnitTestingDocs(outputFolder, command);
await removeExcludedDocs(outputFolder);
await removeExcludedPackageEntries(outputFolder);
}

/**
* Remove markdown files generated for excluded packages.
*/
async function removeExcludedDocs(mainDocsFolder: string) {
console.log('Removing excluded docs from', EXCLUDED_PACKAGES.join(', '));
for (const excludedPackage of EXCLUDED_PACKAGES) {
Expand All @@ -211,13 +215,34 @@ async function removeExcludedDocs(mainDocsFolder: string) {
resolve(paths);
})
);
console.log('glob pattern', `${mainDocsFolder}/${excludedPackage}.*`);
for (const excludedMdFile of excludedMdFiles) {
fs.unlinkSync(excludedMdFile);
}
}
}

/**
* Remove lines from index.md that link to excluded packages.
*/
async function removeExcludedPackageEntries(mainDocsFolder: string) {
console.log(`Removing ${EXCLUDED_PACKAGES.join(', ')} from index page.`);
const indexText = fs.readFileSync(`${mainDocsFolder}/index.md`, 'utf-8');
const indexTextLines = indexText.split('\n');
const newIndexTextLines = indexTextLines.filter(line => {
for (const excludedPackage of EXCLUDED_PACKAGES) {
if (line.includes(`[@firebase/${excludedPackage}]`)) {
return false;
}
}
return true;
});
fs.writeFileSync(
`${mainDocsFolder}/index.md`,
newIndexTextLines.join('\n'),
'utf-8'
);
}

// Create a docs-rut folder and move rules-unit-testing docs into it.
async function moveRulesUnitTestingDocs(
mainDocsFolder: string,
Expand Down