From c271d16a9c8164880eacc656a9933644bd3d419e Mon Sep 17 00:00:00 2001 From: Christina Holland Date: Tue, 11 Jan 2022 10:31:22 -0800 Subject: [PATCH] Add a header comment to devsite md files. (#5865) * Add a header comment to devsite md files. * formatting --- scripts/docgen/docgen.ts | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/scripts/docgen/docgen.ts b/scripts/docgen/docgen.ts index d87815ea83c..d82a48e4d56 100644 --- a/scripts/docgen/docgen.ts +++ b/scripts/docgen/docgen.ts @@ -20,8 +20,21 @@ import { mapWorkspaceToPackages } from '../release/utils/workspace'; import { projectRoot } from '../utils'; import fs from 'fs'; import glob from 'glob'; +import { join } from 'path'; import * as yargs from 'yargs'; +/** + * Add to devsite files to alert anyone trying to make a documentation fix + * to the generated files. + */ +const GOOGLE3_HEADER = `{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} +`; + const tmpDir = `${projectRoot}/temp`; yargs @@ -101,6 +114,15 @@ async function generateDocs(forDevsite: boolean = false) { { stdio: 'inherit' } ); + if (forDevsite) { + const mdFiles = fs.readdirSync(join(projectRoot, outputFolder)); + for (const mdFile of mdFiles) { + const fullPath = join(projectRoot, outputFolder, mdFile); + const content = fs.readFileSync(fullPath, 'utf-8'); + fs.writeFileSync(fullPath, GOOGLE3_HEADER + content); + } + } + moveRulesUnitTestingDocs(outputFolder, command); }