Skip to content

Commit 417a5d4

Browse files
authored
Remove excluded packages from doc index.md (#6651)
1 parent 4eb8145 commit 417a5d4

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

scripts/docgen/docgen.ts

+26-1
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,12 @@ async function generateDocs(
200200

201201
await moveRulesUnitTestingDocs(outputFolder, command);
202202
await removeExcludedDocs(outputFolder);
203+
await removeExcludedPackageEntries(outputFolder);
203204
}
204205

206+
/**
207+
* Remove markdown files generated for excluded packages.
208+
*/
205209
async function removeExcludedDocs(mainDocsFolder: string) {
206210
console.log('Removing excluded docs from', EXCLUDED_PACKAGES.join(', '));
207211
for (const excludedPackage of EXCLUDED_PACKAGES) {
@@ -211,13 +215,34 @@ async function removeExcludedDocs(mainDocsFolder: string) {
211215
resolve(paths);
212216
})
213217
);
214-
console.log('glob pattern', `${mainDocsFolder}/${excludedPackage}.*`);
215218
for (const excludedMdFile of excludedMdFiles) {
216219
fs.unlinkSync(excludedMdFile);
217220
}
218221
}
219222
}
220223

224+
/**
225+
* Remove lines from index.md that link to excluded packages.
226+
*/
227+
async function removeExcludedPackageEntries(mainDocsFolder: string) {
228+
console.log(`Removing ${EXCLUDED_PACKAGES.join(', ')} from index page.`);
229+
const indexText = fs.readFileSync(`${mainDocsFolder}/index.md`, 'utf-8');
230+
const indexTextLines = indexText.split('\n');
231+
const newIndexTextLines = indexTextLines.filter(line => {
232+
for (const excludedPackage of EXCLUDED_PACKAGES) {
233+
if (line.includes(`[@firebase/${excludedPackage}]`)) {
234+
return false;
235+
}
236+
}
237+
return true;
238+
});
239+
fs.writeFileSync(
240+
`${mainDocsFolder}/index.md`,
241+
newIndexTextLines.join('\n'),
242+
'utf-8'
243+
);
244+
}
245+
221246
// Create a docs-rut folder and move rules-unit-testing docs into it.
222247
async function moveRulesUnitTestingDocs(
223248
mainDocsFolder: string,

0 commit comments

Comments
 (0)