Skip to content
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

chore: fix broken docs build / remove unused tag files #2402

Merged
merged 3 commits into from
Nov 11, 2022
Merged
Show file tree
Hide file tree
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
41 changes: 27 additions & 14 deletions website/clean-generated-docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,40 @@
// save us loooots of questions.
const replace = require('replace-in-file');

const escapeCharacters = (input) => {
unquotedInput =
input.charAt(0) === '"' ? input.substring(1, input.length - 1) : input;
const fixed = unquotedInput.replace(/(?<!\\)"/g, '\\"');
return `"${fixed}"`;
};

const options = {
files: 'docs/reference/api/**/*.api.mdx',
from: [
/\/ushosted/g,
/"https:\/\/us.app.unleash-hosted.com(\/ushosted)?"/g,
'"path":["ushosted",',
/^(sidebar_label|title): (.+)/gm, // escape potentially unescaped, single-line text fields
],
to: [
'',
'"<your-unleash-url>"',
'"path":[',
(_, key, description) => `${key}: ${escapeCharacters(description)}`,
],
to: ['', '"<your-unleash-url>"', '"path":['],
};

replace(options);

// remove unused tag files: https://github.com/Unleash/unleash/pull/2402
const fs = require('fs');

const unleashOpenApiDirectory = './docs/reference/api/unleash';
const unleashApiSidebar = require(`${unleashOpenApiDirectory}/sidebar.js`);

const tagsInSidebar = new Set(
unleashApiSidebar
.map((item) => item.link?.id)
.filter(Boolean)
.map((link) => link.substring(link.lastIndexOf('/') + 1)),
);

const tagsInFiles = fs
.readdirSync(unleashOpenApiDirectory)
.filter((file) => file.endsWith('.tag.mdx'))
.map((file) => file.substring(0, file.indexOf('.')));

const unusedTags = tagsInFiles.filter((tag) => !tagsInSidebar.has(tag));

for (const tag of unusedTags) {
const file = `${unleashOpenApiDirectory}/${tag}.tag.mdx`;
fs.rmSync(file);
console.info('Deleted unused OpenAPI tag file:', file);
}
18 changes: 10 additions & 8 deletions website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,19 @@
"build-storybook": "build-storybook"
},
"dependencies": {
"@docusaurus/core": "2.1.0",
"@docusaurus/plugin-client-redirects": "2.1.0",
"@docusaurus/plugin-google-analytics": "2.1.0",
"@docusaurus/preset-classic": "2.1.0",
"@docusaurus/remark-plugin-npm2yarn": "2.1.0",
"@docusaurus/core": "2.2.0",
"@docusaurus/plugin-client-redirects": "2.2.0",
"@docusaurus/plugin-google-analytics": "2.2.0",
"@docusaurus/preset-classic": "2.2.0",
"@docusaurus/remark-plugin-npm2yarn": "2.2.0",
"@mdx-js/react": "1.6.22",
"@svgr/webpack": "6.5.1",
"browserslist": "^4.16.5",
"clsx": "1.2.1",
"docusaurus-plugin-openapi-docs": "1.4.1",
"docusaurus-theme-openapi-docs": "1.4.1",
"docusaurus-plugin-openapi-docs": "0.0.0-507",
"docusaurus-theme-openapi-docs": "0.0.0-507",
Comment on lines +32 to +33
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moving from a released version (1.4.1) to 0.0.0-<> ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Canary release that includes fixes for 2.2.0. Should be in the next release, but this fixes the issue for now. We may be able to roll back to 1.4.3 with docusaurus 2.1.0, however. I can look into it on monday unless we just want to wait it out.

"file-loader": "6.2.0",
"immer": "^9.0.6",
"react": "18.2.0",
"react-dom": "18.2.0",
"unleash-proxy-client": "2.3.0",
Expand Down Expand Up @@ -64,7 +66,7 @@
},
"devDependencies": {
"@babel/core": "7.19.6",
"@docusaurus/module-type-aliases": "2.1.0",
"@docusaurus/module-type-aliases": "2.2.0",
"@storybook/addon-actions": "6.5.13",
"@storybook/addon-essentials": "6.5.13",
"@storybook/addon-interactions": "6.5.13",
Expand Down
Loading