From bb92983e6caf8bc2db7a4ef3cf5bd30b6c30c906 Mon Sep 17 00:00:00 2001 From: Ben Webb Date: Fri, 31 Jan 2025 14:08:37 -0500 Subject: [PATCH 1/5] testing --- package-lock.json | 16 +++---- packages/docs/package.json | 2 +- packages/docs/src/templates/style.ts | 69 ++++++++++++++++++++++------ 3 files changed, 64 insertions(+), 23 deletions(-) diff --git a/package-lock.json b/package-lock.json index eafb12f52..779e23d8f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3106,12 +3106,12 @@ } }, "node_modules/@oruga-ui/theme-bulma": { - "version": "0.5.2", - "resolved": "https://registry.npmjs.org/@oruga-ui/theme-bulma/-/theme-bulma-0.5.2.tgz", - "integrity": "sha512-dhHaI/ES8l5NBfVy6j4JD8ShkSwviOnZrrn4dzqO63ZXpd64Kql+Z9S/7Y++D1JcQVgqwmTjB+UbeJJjiWVXpA==", + "version": "0.5.3", + "resolved": "file:../theme-bulma/oruga-ui-theme-bulma-0.5.3.tgz", + "integrity": "sha512-/3E9/BZL+8u1oLzyf/Z+/o8Q0FyjHzSM09VXdxXUFLfO3yd9TMZD2vz5sXxAev5EodVrHsDen+1ACitQuo5C5g==", "license": "MIT", "dependencies": { - "bulma": "1.0.2" + "bulma": "1.0.3" }, "peerDependencies": { "@oruga-ui/oruga-next": "^0.9.0" @@ -5378,9 +5378,9 @@ } }, "node_modules/bulma": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/bulma/-/bulma-1.0.2.tgz", - "integrity": "sha512-D7GnDuF6seb6HkcnRMM9E739QpEY9chDzzeFrHMyEns/EXyDJuQ0XA0KxbBl/B2NTsKSoDomW61jFGFaAxhK5A==", + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/bulma/-/bulma-1.0.3.tgz", + "integrity": "sha512-9eVXBrXwlU337XUXBjIIq7i88A+tRbJYAjXQjT/21lwam+5tpvKF0R7dCesre9N+HV9c6pzCNEPKrtgvBBes2g==", "license": "MIT" }, "node_modules/cac": { @@ -11999,7 +11999,7 @@ "@fortawesome/vue-fontawesome": "^3.0.8", "@highlightjs/vue-plugin": "2.1.2", "@oruga-ui/theme-bootstrap": "0.7.2", - "@oruga-ui/theme-bulma": "0.5.2", + "@oruga-ui/theme-bulma": "file:../../../theme-bulma/oruga-ui-theme-bulma-0.5.3.tgz", "@oruga-ui/theme-oruga": "0.5.0", "highlight.js": "11.11.0", "markdown-it": "^14.1.0", diff --git a/packages/docs/package.json b/packages/docs/package.json index c9d2e4e40..eb4dfbf3d 100644 --- a/packages/docs/package.json +++ b/packages/docs/package.json @@ -23,7 +23,7 @@ "@fortawesome/vue-fontawesome": "^3.0.8", "@highlightjs/vue-plugin": "2.1.2", "@oruga-ui/theme-bootstrap": "0.7.2", - "@oruga-ui/theme-bulma": "0.5.2", + "@oruga-ui/theme-bulma": "file:../../../theme-bulma/oruga-ui-theme-bulma-0.5.3.tgz", "@oruga-ui/theme-oruga": "0.5.0", "highlight.js": "11.11.0", "markdown-it": "^14.1.0", diff --git a/packages/docs/src/templates/style.ts b/packages/docs/src/templates/style.ts index 6ec367516..65114a9f5 100644 --- a/packages/docs/src/templates/style.ts +++ b/packages/docs/src/templates/style.ts @@ -3,6 +3,20 @@ import * as fs from "fs"; import { type SafeDocgenCLIConfig } from "vue-docgen-cli/lib/config"; import { getThemePath, Themes, type ThemeConfig } from "../themes-helper"; +export const docsRegex = "/* @docs */"; + +export function getVariablesFromContent(content: string) { + const docs = content.substring( + content.indexOf(docsRegex) + docsRegex.length, + content.lastIndexOf(docsRegex), + ); + + return docs + .replace(/(\r\n|\n|\r)/gm, "") + .split(";") + .filter((d) => !!d); +} + export function renderer(config: SafeDocgenCLIConfig, name: string): string { const renderThemeVariables = (theme: ThemeConfig): string => { const noStyle = `

The theme does not have any custom variables for this component.

`; @@ -11,23 +25,50 @@ export function renderer(config: SafeDocgenCLIConfig, name: string): string { config.cwd, `/scss/components/${name}`, ); - if (!componentPath) return noStyle; + const componentDefaultsPath = getThemePath( + theme, + config.cwd, + `/scss/component-defaults/${name}`, + ); - const cssFile = path.resolve(config.cwd, componentPath); - const content = fs.readFileSync(cssFile, "utf8"); - const docsRegex = "/* @docs */"; + if (!componentPath && !componentDefaultsPath) return noStyle; - if (!content.includes(docsRegex)) return noStyle; + let cssContent = ""; + let defaultsContent = ""; - const docs = content.substring( - content.indexOf(docsRegex) + docsRegex.length, - content.lastIndexOf(docsRegex), - ); + try { + const cssFile = path.resolve(config.cwd, componentPath); + cssContent = fs.readFileSync(cssFile, "utf8"); + } catch (e) { + // Log errors but allow the process to continue. We expect every component to have a scss file, but docs should render even if none is found + console.error(e); + } + + try { + const defaultsFile = path.resolve( + config.cwd, + componentDefaultsPath, + ); + defaultsContent = fs.readFileSync(defaultsFile, "utf8"); + // eslint-disable-next-line @typescript-eslint/no-unused-vars + } catch (e) { + // Swallow error and move on. We expect some components will not have defaults. + } + + if ( + !cssContent.includes(docsRegex) && + !defaultsContent.includes(docsRegex) + ) + return noStyle; + + if (name === "_skeleton.scss") { + console.error("???", name, cssContent, defaultsContent); + } - const variables = docs - .replace(/(\r\n|\n|\r)/gm, "") - .split(";") - .filter((d) => !!d); + const variables = [ + ...getVariablesFromContent(cssContent), + ...getVariablesFromContent(defaultsContent), + ]; return ` | SASS Variable | Default | @@ -51,7 +92,7 @@ See ➜ 📄 [Full scss file](${theme.src}/scss/components/${name}) ## Sass variables ${Themes.map( - (theme) => + (theme: ThemeConfig) => `
> Current theme ➜ _[${theme.label}](${theme.git})_ From 99202a84c584666dd3b33b345547ae91b3d6adde Mon Sep 17 00:00:00 2001 From: Ben Webb Date: Fri, 31 Jan 2025 14:25:17 -0500 Subject: [PATCH 2/5] revert back to latest theme bulma --- package-lock.json | 51 ++++++++++++++++++++++++-------------- packages/docs/package.json | 2 +- 2 files changed, 33 insertions(+), 20 deletions(-) diff --git a/package-lock.json b/package-lock.json index 779e23d8f..03e1f2719 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3105,18 +3105,6 @@ "@oruga-ui/oruga-next": "^0.9.0" } }, - "node_modules/@oruga-ui/theme-bulma": { - "version": "0.5.3", - "resolved": "file:../theme-bulma/oruga-ui-theme-bulma-0.5.3.tgz", - "integrity": "sha512-/3E9/BZL+8u1oLzyf/Z+/o8Q0FyjHzSM09VXdxXUFLfO3yd9TMZD2vz5sXxAev5EodVrHsDen+1ACitQuo5C5g==", - "license": "MIT", - "dependencies": { - "bulma": "1.0.3" - }, - "peerDependencies": { - "@oruga-ui/oruga-next": "^0.9.0" - } - }, "node_modules/@parcel/watcher": { "version": "2.5.0", "resolved": "https://registry.npmjs.org/@parcel/watcher/-/watcher-2.5.0.tgz", @@ -5377,12 +5365,6 @@ "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7" } }, - "node_modules/bulma": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/bulma/-/bulma-1.0.3.tgz", - "integrity": "sha512-9eVXBrXwlU337XUXBjIIq7i88A+tRbJYAjXQjT/21lwam+5tpvKF0R7dCesre9N+HV9c6pzCNEPKrtgvBBes2g==", - "license": "MIT" - }, "node_modules/cac": { "version": "6.7.14", "resolved": "https://registry.npmjs.org/cac/-/cac-6.7.14.tgz", @@ -11999,7 +11981,7 @@ "@fortawesome/vue-fontawesome": "^3.0.8", "@highlightjs/vue-plugin": "2.1.2", "@oruga-ui/theme-bootstrap": "0.7.2", - "@oruga-ui/theme-bulma": "file:../../../theme-bulma/oruga-ui-theme-bulma-0.5.3.tgz", + "@oruga-ui/theme-bulma": "0.5.2", "@oruga-ui/theme-oruga": "0.5.0", "highlight.js": "11.11.0", "markdown-it": "^14.1.0", @@ -12025,6 +12007,31 @@ "vue-tsc": "^2.1.10" } }, + "packages/docs/node_modules/@oruga-ui/oruga-next": { + "version": "0.9.0", + "resolved": "https://registry.npmjs.org/@oruga-ui/oruga-next/-/oruga-next-0.9.0.tgz", + "integrity": "sha512-k25URBruttk2u+pj0NsCXwbCE1OyORhv4jpHh7BXR9zAHHSSKwV1Evbbvbr77/wVRWhbgoso1IOxc8WaT9Fr5g==", + "license": "MIT", + "peer": true, + "dependencies": { + "vue-component-type-helpers": "^2.1.10" + }, + "peerDependencies": { + "vue": "^3.0.0" + } + }, + "packages/docs/node_modules/@oruga-ui/theme-bulma": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/@oruga-ui/theme-bulma/-/theme-bulma-0.5.2.tgz", + "integrity": "sha512-dhHaI/ES8l5NBfVy6j4JD8ShkSwviOnZrrn4dzqO63ZXpd64Kql+Z9S/7Y++D1JcQVgqwmTjB+UbeJJjiWVXpA==", + "license": "MIT", + "dependencies": { + "bulma": "1.0.2" + }, + "peerDependencies": { + "@oruga-ui/oruga-next": "^0.9.0" + } + }, "packages/docs/node_modules/@oruga-ui/theme-oruga": { "version": "0.5.0", "resolved": "https://registry.npmjs.org/@oruga-ui/theme-oruga/-/theme-oruga-0.5.0.tgz", @@ -12034,6 +12041,12 @@ "@oruga-ui/oruga-next": "0.9.0" } }, + "packages/docs/node_modules/bulma": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/bulma/-/bulma-1.0.2.tgz", + "integrity": "sha512-D7GnDuF6seb6HkcnRMM9E739QpEY9chDzzeFrHMyEns/EXyDJuQ0XA0KxbBl/B2NTsKSoDomW61jFGFaAxhK5A==", + "license": "MIT" + }, "packages/docs/node_modules/typescript": { "version": "5.6.3", "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.6.3.tgz", diff --git a/packages/docs/package.json b/packages/docs/package.json index eb4dfbf3d..c9d2e4e40 100644 --- a/packages/docs/package.json +++ b/packages/docs/package.json @@ -23,7 +23,7 @@ "@fortawesome/vue-fontawesome": "^3.0.8", "@highlightjs/vue-plugin": "2.1.2", "@oruga-ui/theme-bootstrap": "0.7.2", - "@oruga-ui/theme-bulma": "file:../../../theme-bulma/oruga-ui-theme-bulma-0.5.3.tgz", + "@oruga-ui/theme-bulma": "0.5.2", "@oruga-ui/theme-oruga": "0.5.0", "highlight.js": "11.11.0", "markdown-it": "^14.1.0", From 8bb1f5db8d5a22dcbf546ae6dfbfea81ee625cef Mon Sep 17 00:00:00 2001 From: Ben Webb Date: Fri, 31 Jan 2025 14:33:37 -0500 Subject: [PATCH 3/5] cleanup --- packages/docs/src/templates/style.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/packages/docs/src/templates/style.ts b/packages/docs/src/templates/style.ts index 65114a9f5..1d4641f1b 100644 --- a/packages/docs/src/templates/style.ts +++ b/packages/docs/src/templates/style.ts @@ -61,10 +61,6 @@ export function renderer(config: SafeDocgenCLIConfig, name: string): string { ) return noStyle; - if (name === "_skeleton.scss") { - console.error("???", name, cssContent, defaultsContent); - } - const variables = [ ...getVariablesFromContent(cssContent), ...getVariablesFromContent(defaultsContent), From e2bc98792d945333dbb45e7a74b3b499a4d6058d Mon Sep 17 00:00:00 2001 From: Ben Webb Date: Fri, 31 Jan 2025 14:36:11 -0500 Subject: [PATCH 4/5] revert lock --- package-lock.json | 49 +++++++++++++++++------------------------------ 1 file changed, 18 insertions(+), 31 deletions(-) diff --git a/package-lock.json b/package-lock.json index 03e1f2719..eafb12f52 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3105,6 +3105,18 @@ "@oruga-ui/oruga-next": "^0.9.0" } }, + "node_modules/@oruga-ui/theme-bulma": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/@oruga-ui/theme-bulma/-/theme-bulma-0.5.2.tgz", + "integrity": "sha512-dhHaI/ES8l5NBfVy6j4JD8ShkSwviOnZrrn4dzqO63ZXpd64Kql+Z9S/7Y++D1JcQVgqwmTjB+UbeJJjiWVXpA==", + "license": "MIT", + "dependencies": { + "bulma": "1.0.2" + }, + "peerDependencies": { + "@oruga-ui/oruga-next": "^0.9.0" + } + }, "node_modules/@parcel/watcher": { "version": "2.5.0", "resolved": "https://registry.npmjs.org/@parcel/watcher/-/watcher-2.5.0.tgz", @@ -5365,6 +5377,12 @@ "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7" } }, + "node_modules/bulma": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/bulma/-/bulma-1.0.2.tgz", + "integrity": "sha512-D7GnDuF6seb6HkcnRMM9E739QpEY9chDzzeFrHMyEns/EXyDJuQ0XA0KxbBl/B2NTsKSoDomW61jFGFaAxhK5A==", + "license": "MIT" + }, "node_modules/cac": { "version": "6.7.14", "resolved": "https://registry.npmjs.org/cac/-/cac-6.7.14.tgz", @@ -12007,31 +12025,6 @@ "vue-tsc": "^2.1.10" } }, - "packages/docs/node_modules/@oruga-ui/oruga-next": { - "version": "0.9.0", - "resolved": "https://registry.npmjs.org/@oruga-ui/oruga-next/-/oruga-next-0.9.0.tgz", - "integrity": "sha512-k25URBruttk2u+pj0NsCXwbCE1OyORhv4jpHh7BXR9zAHHSSKwV1Evbbvbr77/wVRWhbgoso1IOxc8WaT9Fr5g==", - "license": "MIT", - "peer": true, - "dependencies": { - "vue-component-type-helpers": "^2.1.10" - }, - "peerDependencies": { - "vue": "^3.0.0" - } - }, - "packages/docs/node_modules/@oruga-ui/theme-bulma": { - "version": "0.5.2", - "resolved": "https://registry.npmjs.org/@oruga-ui/theme-bulma/-/theme-bulma-0.5.2.tgz", - "integrity": "sha512-dhHaI/ES8l5NBfVy6j4JD8ShkSwviOnZrrn4dzqO63ZXpd64Kql+Z9S/7Y++D1JcQVgqwmTjB+UbeJJjiWVXpA==", - "license": "MIT", - "dependencies": { - "bulma": "1.0.2" - }, - "peerDependencies": { - "@oruga-ui/oruga-next": "^0.9.0" - } - }, "packages/docs/node_modules/@oruga-ui/theme-oruga": { "version": "0.5.0", "resolved": "https://registry.npmjs.org/@oruga-ui/theme-oruga/-/theme-oruga-0.5.0.tgz", @@ -12041,12 +12034,6 @@ "@oruga-ui/oruga-next": "0.9.0" } }, - "packages/docs/node_modules/bulma": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/bulma/-/bulma-1.0.2.tgz", - "integrity": "sha512-D7GnDuF6seb6HkcnRMM9E739QpEY9chDzzeFrHMyEns/EXyDJuQ0XA0KxbBl/B2NTsKSoDomW61jFGFaAxhK5A==", - "license": "MIT" - }, "packages/docs/node_modules/typescript": { "version": "5.6.3", "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.6.3.tgz", From a8624ec4c8606b789a8ac9e8f1c4478a751b7617 Mon Sep 17 00:00:00 2001 From: Ben Webb Date: Fri, 31 Jan 2025 14:37:22 -0500 Subject: [PATCH 5/5] remove uneccisary type --- packages/docs/src/templates/style.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/docs/src/templates/style.ts b/packages/docs/src/templates/style.ts index 1d4641f1b..8e2e862f3 100644 --- a/packages/docs/src/templates/style.ts +++ b/packages/docs/src/templates/style.ts @@ -88,7 +88,7 @@ See ➜ 📄 [Full scss file](${theme.src}/scss/components/${name}) ## Sass variables ${Themes.map( - (theme: ThemeConfig) => + (theme) => `
> Current theme ➜ _[${theme.label}](${theme.git})_