From 451438fc34ba6b623d74d2199c882c7d99ab2aed Mon Sep 17 00:00:00 2001 From: tasneemkoushar Date: Fri, 2 Jul 2021 15:19:18 +0530 Subject: [PATCH 1/4] fix: added script --- package.json | 2 +- utils/remove-tag.js | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 utils/remove-tag.js diff --git a/package.json b/package.json index 4c8d635470dd5..0bdb101bc1d17 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "test-install": "scripts/test-install.sh", "clean-docs": "rimraf new-docs && rimraf docs-api-json", "generate-d-ts": "npm run clean-docs && api-extractor run --local --verbose", - "generate-docs": "npm run generate-d-ts && api-documenter markdown -i docs-api-json -o new-docs", + "generate-docs": "npm run generate-d-ts && api-documenter markdown -i docs-api-json -o new-docs && node utils/remove-tag.js", "ensure-correct-devtools-protocol-revision": "ts-node -s scripts/ensure-correct-devtools-protocol-package", "ensure-pinned-deps": "ts-node -s scripts/ensure-pinned-deps", "test-types-file": "ts-node -s scripts/test-ts-definition-files.ts", diff --git a/utils/remove-tag.js b/utils/remove-tag.js new file mode 100644 index 0000000000000..e5c3f3b060776 --- /dev/null +++ b/utils/remove-tag.js @@ -0,0 +1,27 @@ +#!/usr/bin/env node +/** + * Copyright 2018 Google Inc. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + const glob = require('glob'); + const fs = require('fs'); + + //look for all .md files in the given location. + const files = glob.sync(`./new-docs/*.md`); + + for (const file of files) { + const content = fs.readFileSync(file, 'utf8'); + const updated = content.replaceAll('', ''); + fs.writeFileSync(file, updated); + } From 29c164c1df1c7893df9dab56f7606c2504d964c8 Mon Sep 17 00:00:00 2001 From: tasneemkoushar Date: Fri, 2 Jul 2021 16:57:50 +0530 Subject: [PATCH 2/4] fix: updated script --- utils/remove-tag.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/utils/remove-tag.js b/utils/remove-tag.js index e5c3f3b060776..5402703db00ae 100644 --- a/utils/remove-tag.js +++ b/utils/remove-tag.js @@ -14,14 +14,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - const glob = require('glob'); - const fs = require('fs'); +const glob = require('glob'); +const fs = require('fs'); - //look for all .md files in the given location. - const files = glob.sync(`./new-docs/*.md`); +// look for all .md files in the given location. +const files = glob.sync(`./new-docs/*.md`); - for (const file of files) { - const content = fs.readFileSync(file, 'utf8'); - const updated = content.replaceAll('', ''); - fs.writeFileSync(file, updated); - } +for (const file of files) { + const content = fs.readFileSync(file, 'utf8'); + const updated = content.replaceAll('', ''); + fs.writeFileSync(file, updated); +} From d450330d1564db9c4a1e5ebf07a48a1a62d1f8c0 Mon Sep 17 00:00:00 2001 From: tasneemkoushar Date: Fri, 2 Jul 2021 17:11:40 +0530 Subject: [PATCH 3/4] fix: updated script --- utils/remove-tag.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/remove-tag.js b/utils/remove-tag.js index 5402703db00ae..b08e8a6c722a9 100644 --- a/utils/remove-tag.js +++ b/utils/remove-tag.js @@ -22,6 +22,6 @@ const files = glob.sync(`./new-docs/*.md`); for (const file of files) { const content = fs.readFileSync(file, 'utf8'); - const updated = content.replaceAll('', ''); + const updated = content.replace(//g, ''); fs.writeFileSync(file, updated); } From a4396df8ee9e4a746e7a25fb6885d29218f21637 Mon Sep 17 00:00:00 2001 From: TASNEEM KOUSHAR Date: Mon, 5 Jul 2021 15:46:35 +0530 Subject: [PATCH 4/4] fix: added comment --- utils/remove-tag.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/utils/remove-tag.js b/utils/remove-tag.js index b08e8a6c722a9..8e29117ba0461 100644 --- a/utils/remove-tag.js +++ b/utils/remove-tag.js @@ -14,6 +14,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +/** + * Docusaurus gets confused by empty HTML comment tags in our Markdown. + These are generated by API Extractor but do not affect the final output, + so to avoid Docusaurus errors we strip them out before generating the website. + **/ const glob = require('glob'); const fs = require('fs');