Skip to content

Commit e151c8b

Browse files
authored
refactor: cleanup legacy descriptions (webstudio-is#5175)
Here dropped legacy descriptions generated with AI. All attributes are using descriptions scraped from html spec. Though many component properties redefine these attributes without descriptions. So to workaround just always fall back to attributes descriptions. Covers most cases.
1 parent 6f792e4 commit e151c8b

27 files changed

Lines changed: 105 additions & 797 deletions

packages/generate-arg-types/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"dependencies": {
1212
"@webstudio-is/html-data": "workspace:*",
1313
"@webstudio-is/sdk": "workspace:*",
14+
"@webstudio-is/react-sdk": "workspace:*",
1415
"fast-glob": "^3.3.2",
1516
"react-docgen-typescript": "^2.2.2",
1617
"typescript": "5.8.2",
Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
import {
2-
domAttributesToReact,
3-
reactPropsToDomAttributes,
4-
} from "@webstudio-is/html-data";
5-
import {
6-
htmlPropsDescriptions,
7-
overridePropsDescriptions,
8-
} from "@webstudio-is/html-data";
2+
reactPropsToStandardAttributes,
3+
standardAttributesToReactProps,
4+
} from "@webstudio-is/react-sdk";
5+
import { ariaAttributes, attributesByTag } from "@webstudio-is/html-data";
96
import { propsToArgTypes } from "../arg-types";
107

118
const ignoreComponents = new Set(["Embed"]);
@@ -31,7 +28,6 @@ export const addDescriptions = (
3128

3229
Object.entries(argTypes).forEach(([propName, meta]) => {
3330
const description = getDescription(
34-
componenName,
3531
propName,
3632
meta.description,
3733
customDescriptions
@@ -43,30 +39,30 @@ export const addDescriptions = (
4339
});
4440
};
4541

42+
const attributeDescriptions: Record<string, string> = {};
43+
for (const attribute of Object.values(attributesByTag).flat()) {
44+
if (attribute) {
45+
attributeDescriptions[attribute.name] = attribute.description;
46+
}
47+
}
48+
for (const attribute of ariaAttributes) {
49+
attributeDescriptions[attribute.name] = attribute.description;
50+
}
51+
4652
export const getDescription = (
47-
componentName: string,
4853
propName: string,
4954
currentDescription: string | undefined,
5055
customDescriptions: { [key in string]: string } = {}
5156
): string | undefined => {
52-
const name = (domAttributesToReact[
53-
propName as keyof typeof domAttributesToReact
54-
] ||
55-
reactPropsToDomAttributes[propName] ||
56-
propName.toLowerCase()) as keyof typeof htmlPropsDescriptions &
57-
keyof typeof overridePropsDescriptions;
58-
57+
const name =
58+
standardAttributesToReactProps[propName] ||
59+
reactPropsToStandardAttributes[propName] ||
60+
propName.toLowerCase();
5961
return (
6062
customDescriptions[propName] ||
6163
customDescriptions[name] ||
62-
overridePropsDescriptions[
63-
propName as keyof typeof overridePropsDescriptions
64-
] ||
65-
overridePropsDescriptions[name] ||
6664
currentDescription ||
67-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
68-
// @ts-ignore
69-
htmlPropsDescriptions[`${componentName.toLowerCase()}:${name}`] ||
70-
htmlPropsDescriptions[name]
65+
attributeDescriptions[propName] ||
66+
attributeDescriptions[name]
7167
);
7268
};

packages/html-data/src/descriptions.ts

Lines changed: 0 additions & 175 deletions
This file was deleted.

0 commit comments

Comments
 (0)