From b7f41388d15a3002751a0ba5a28043528945a758 Mon Sep 17 00:00:00 2001 From: Evan Date: Sat, 4 Feb 2023 14:16:18 -0500 Subject: [PATCH] feat(docs): allow object passed to propComponents to customize component source --- packages/documentation-framework/scripts/md/parseMD.js | 5 ++++- .../content/extensions/extension/examples/basic.md | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/documentation-framework/scripts/md/parseMD.js b/packages/documentation-framework/scripts/md/parseMD.js index 9f2a91e7a9..294ea9a60e 100644 --- a/packages/documentation-framework/scripts/md/parseMD.js +++ b/packages/documentation-framework/scripts/md/parseMD.js @@ -61,7 +61,10 @@ function toReactComponent(mdFilePath, source, buildMode) { } const propComponents = [...new Set(frontmatter.propComponents || [])].reduce((acc, componentName) => { - const name = getTsDocName(componentName, getTsDocNameVariant(source)); + // Use object properties if passed as propComponent + const component = componentName.component || componentName; + const src = componentName.source || source; + const name = getTsDocName(component, getTsDocNameVariant(src)); if (tsDocs[name]) { acc.push(tsDocs[name]); diff --git a/packages/documentation-framework/templates/patternfly-docs/content/extensions/extension/examples/basic.md b/packages/documentation-framework/templates/patternfly-docs/content/extensions/extension/examples/basic.md index 137ca95fcd..b1faa04353 100644 --- a/packages/documentation-framework/templates/patternfly-docs/content/extensions/extension/examples/basic.md +++ b/packages/documentation-framework/templates/patternfly-docs/content/extensions/extension/examples/basic.md @@ -9,6 +9,7 @@ id: My extension source: react # If you use typescript, the name of the interface to display props for # These are found through the sourceProps function provdided in patternfly-docs.source.js +# Can also pass object { component: string, source: string } allowing to specify the source propComponents: ['Button'] ---