Skip to content

Commit

Permalink
Fix data grid props tables all incorrectly extending HTML elements
Browse files Browse the repository at this point in the history
- this is due to all the components existing on the same page, which typically doesn't happen

- we need to switch to a per-component array which doesn't get polluted as easily
  • Loading branch information
cee-chen committed Dec 6, 2024
1 parent 7e1de33 commit 0d2a303
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
13 changes: 9 additions & 4 deletions packages/eui-docgen/src/filter_prop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const allowedComponents = ['EuiDataGridVirtualizationOptions'];
export const filterProp = (
prop: PropItem,
component: any,
componentExtends: string[]
componentExtends: Record<string, string[]>
) => {
if (allowedProps.includes(prop.name)) {
return true;
Expand Down Expand Up @@ -82,11 +82,16 @@ export const filterProp = (
}

if (prop.parent) {
//Check if props are extended from other node module
// Check if props are extended from other node module
if (allowedParents.includes(prop.parent.name)) return true;
if (!componentExtends.includes(prop.parent.name)) {
componentExtends.push(prop.parent.name);

if (!componentExtends[component.name]) {
componentExtends[component.name] = [];
}
if (!componentExtends[component.name].includes(prop.parent.name)) {
componentExtends[component.name].push(prop.parent.name);
}

if (allowedProps.includes(prop.name)) {
return true;
}
Expand Down
4 changes: 2 additions & 2 deletions packages/eui-docgen/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const main = async () => {
for (const file of files) {
const fileRelativePath = path.relative(euiSrcPath, file);

const componentExtends: Array<string> = [];
const componentExtends: Record<string, string[]> = {};
const parser = docgen.withCustomConfig(path.join(euiPackagePath, 'tsconfig.json'), {
propFilter: (prop, component) => filterProp(prop, component, componentExtends),
shouldExtractLiteralValuesFromEnum: true,
Expand All @@ -51,7 +51,7 @@ const main = async () => {
const processedComponent = processComponent({
componentDoc: parsedComponent,
filePath: fileRelativePath,
componentExtends: componentExtends,
componentExtends: componentExtends[parsedComponent.displayName] || [],
});

if (!processedComponent) {
Expand Down

0 comments on commit 0d2a303

Please sign in to comment.