@@ -601,6 +601,59 @@ describe('MarkdownFormatter - formatComponentManifest', () => {
601601 ` ) ;
602602 } ) ;
603603
604+ it ( 'should format props from reactComponentMeta' , ( ) => {
605+ const manifest : ComponentManifest = {
606+ id : 'button' ,
607+ name : 'Button' ,
608+ path : 'src/components/Button.tsx' ,
609+ reactComponentMeta : {
610+ displayName : 'Button' ,
611+ filePath : 'src/components/Button.tsx' ,
612+ description : '' ,
613+ exportName : 'Button' ,
614+ props : {
615+ variant : {
616+ name : 'variant' ,
617+ description : 'The visual style variant' ,
618+ type : { name : 'enum' , raw : '"primary" | "secondary"' } ,
619+ defaultValue : { value : '"primary"' } ,
620+ required : false ,
621+ } ,
622+ onClick : {
623+ name : 'onClick' ,
624+ description : 'Click handler' ,
625+ type : { name : '(event: MouseEvent) => void' } ,
626+ defaultValue : null ,
627+ required : true ,
628+ } ,
629+ } ,
630+ } ,
631+ } ;
632+
633+ const result = formatComponentManifest ( manifest ) ;
634+
635+ expect ( result ) . toMatchInlineSnapshot ( `
636+ "# Button
637+
638+ ID: button
639+
640+ ## Props
641+
642+ \`\`\`
643+ export type Props = {
644+ /**
645+ The visual style variant
646+ */
647+ variant?: "primary" | "secondary" = "primary";
648+ /**
649+ Click handler
650+ */
651+ onClick: (event: MouseEvent) => void;
652+ }
653+ \`\`\`"
654+ ` ) ;
655+ } ) ;
656+
604657 it ( 'should prefer reactDocgen over reactDocgenTypescript when both are present' , ( ) => {
605658 const manifest : ComponentManifest = {
606659 id : 'button' ,
@@ -638,6 +691,50 @@ describe('MarkdownFormatter - formatComponentManifest', () => {
638691 expect ( result ) . not . toContain ( 'From react-docgen-typescript' ) ;
639692 } ) ;
640693
694+ it ( 'should prefer reactDocgenTypescript over reactComponentMeta when both are present' , ( ) => {
695+ const manifest : ComponentManifest = {
696+ id : 'button' ,
697+ name : 'Button' ,
698+ path : 'src/components/Button.tsx' ,
699+ reactDocgenTypescript : {
700+ displayName : 'Button' ,
701+ filePath : 'src/components/Button.tsx' ,
702+ description : '' ,
703+ exportName : 'Button' ,
704+ methods : [ ] ,
705+ props : {
706+ label : {
707+ name : 'label' ,
708+ description : 'From react-docgen-typescript' ,
709+ type : { name : 'string' } ,
710+ defaultValue : null ,
711+ required : true ,
712+ } ,
713+ } ,
714+ } ,
715+ reactComponentMeta : {
716+ displayName : 'Button' ,
717+ filePath : 'src/components/Button.tsx' ,
718+ description : '' ,
719+ exportName : 'Button' ,
720+ props : {
721+ label : {
722+ name : 'label' ,
723+ description : 'From react-component-meta' ,
724+ type : { name : 'string' } ,
725+ defaultValue : null ,
726+ required : true ,
727+ } ,
728+ } ,
729+ } ,
730+ } ;
731+
732+ const result = formatComponentManifest ( manifest ) ;
733+
734+ expect ( result ) . toContain ( 'From react-docgen-typescript' ) ;
735+ expect ( result ) . not . toContain ( 'From react-component-meta' ) ;
736+ } ) ;
737+
641738 it ( 'should limit stories when reactDocgenTypescript has props' , ( ) => {
642739 const manifest : ComponentManifest = {
643740 id : 'button' ,
@@ -688,6 +785,54 @@ describe('MarkdownFormatter - formatComponentManifest', () => {
688785 expect ( result ) . toContain ( '- WithIcon: Button with an icon' ) ;
689786 } ) ;
690787
788+ it ( 'should limit stories when reactComponentMeta has props' , ( ) => {
789+ const manifest : ComponentManifest = {
790+ id : 'button' ,
791+ name : 'Button' ,
792+ path : 'src/components/Button.tsx' ,
793+ import : 'import { Button } from "@/components";' ,
794+ stories : [
795+ { name : 'Default' , snippet : '<Button>Default</Button>' } ,
796+ { name : 'Primary' , snippet : '<Button variant="primary">Primary</Button>' } ,
797+ { name : 'Secondary' , snippet : '<Button variant="secondary">Secondary</Button>' } ,
798+ {
799+ name : 'Disabled' ,
800+ summary : 'Button in disabled state' ,
801+ snippet : '<Button disabled>Disabled</Button>' ,
802+ } ,
803+ {
804+ name : 'WithIcon' ,
805+ description : 'Button with an icon' ,
806+ snippet : '<Button icon="check">With Icon</Button>' ,
807+ } ,
808+ ] ,
809+ reactComponentMeta : {
810+ displayName : 'Button' ,
811+ filePath : 'src/components/Button.tsx' ,
812+ description : '' ,
813+ exportName : 'Button' ,
814+ props : {
815+ variant : {
816+ name : 'variant' ,
817+ description : '' ,
818+ type : { name : 'string' } ,
819+ defaultValue : null ,
820+ required : false ,
821+ } ,
822+ } ,
823+ } ,
824+ } ;
825+
826+ const result = formatComponentManifest ( manifest ) ;
827+
828+ expect ( result ) . toContain ( '### Default' ) ;
829+ expect ( result ) . toContain ( '### Primary' ) ;
830+ expect ( result ) . toContain ( '### Secondary' ) ;
831+ expect ( result ) . toContain ( '### Other Stories' ) ;
832+ expect ( result ) . toContain ( '- Disabled: Button in disabled state' ) ;
833+ expect ( result ) . toContain ( '- WithIcon: Button with an icon' ) ;
834+ } ) ;
835+
691836 it ( 'should format props with only name and type as bullet list' , ( ) => {
692837 const manifest : ComponentManifest = {
693838 id : 'button' ,
0 commit comments