Skip to content

Commit 4c708b3

Browse files
authored
Merge pull request #312 from appbak3r/feat/add-parents-prop-information
Add more information about parent declaration
2 parents d5c9905 + dffbda4 commit 4c708b3

19 files changed

+195
-81
lines changed

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,12 @@ type PropFilter = (prop: PropItem, component: Component) => boolean;
109109

110110
const options = {
111111
propFilter: (prop: PropItem, component: Component) => {
112-
if (prop.parent) {
113-
return !prop.parent.fileName.includes("node_modules");
112+
if (prop.declarations !== undefined && prop.declarations.length > 0) {
113+
const hasPropAdditionalDescription = prop.declarations.find((declaration) => {
114+
return !declaration.fileName.includes("node_modules");
115+
});
116+
117+
return Boolean(hasPropAdditionalDescription);
114118
}
115119

116120
return true;
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { FC, PropsWithRef } from 'react';
2+
3+
type HTMLButtonProps = JSX.IntrinsicElements['button'];
4+
5+
type Props = HTMLButtonProps & {
6+
/** onClick event handler */
7+
onClick?: HTMLButtonProps['onClick'];
8+
};
9+
10+
const ButtonWithOnClickComponent: FC<Props> = props => {
11+
return <button {...props} />;
12+
};
13+
14+
export default ButtonWithOnClickComponent;

src/__tests__/data/ColumnWithStaticComponents.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ interface LabelProps {
66
}
77

88
/** Column.Label description */
9-
const SubComponent = (props: LabelProps) => <div>My Property = {props.title}</div>;
9+
const SubComponent = (props: LabelProps) => (
10+
<div>My Property = {props.title}</div>
11+
);
1012

1113
/**
1214
* Column properties.
@@ -24,8 +26,8 @@ export class Column extends React.Component<IColumnProps, {}> {
2426

2527
/** Column.SubLabel description */
2628
public static SubLabel() {
27-
return <div>sub</div>
28-
};
29+
return <div>sub</div>;
30+
}
2931

3032
public render() {
3133
const { prop1 } = this.props;

src/__tests__/data/ComplexGenericUnionIntersection.tsx

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,23 @@ declare type PropsOf<
33
> = JSX.LibraryManagedAttributes<E, React.ComponentPropsWithoutRef<E>>;
44

55
/** Props for a Box component that supports the "innerRef" and "as" props. */
6-
type BoxProps<E extends React.ElementType, P = any> = P & PropsOf<E> & {
7-
/** Render the component as another component */
8-
as?: E;
9-
};
6+
type BoxProps<E extends React.ElementType, P = any> = P &
7+
PropsOf<E> & {
8+
/** Render the component as another component */
9+
as?: E;
10+
};
1011

1112
interface StackBaseProps {
1213
/** The flex "align" property */
13-
align?: "stretch" | "center" | "flex-start" | "flex-end";
14+
align?: 'stretch' | 'center' | 'flex-start' | 'flex-end';
1415
}
1516

1617
interface StackJustifyProps {
1718
/**
1819
* Use flex 'space-between' | 'space-around' | 'space-evenly' and
1920
* flex will space the children.
2021
*/
21-
justify?: "space-between" | "space-around" | "space-evenly";
22+
justify?: 'space-between' | 'space-around' | 'space-evenly';
2223
/** You cannot use gap when using a "space" justify property */
2324
gap?: never;
2425
}
@@ -28,18 +29,18 @@ interface StackGapProps {
2829
* Use flex 'center' | 'flex-start' | 'flex-end' | 'stretch' with
2930
* a gap between each child.
3031
*/
31-
justify?: "center" | "flex-start" | "flex-end" | "stretch";
32+
justify?: 'center' | 'flex-start' | 'flex-end' | 'stretch';
3233
/** The space between children */
3334
gap?: number | string;
3435
}
3536

3637
type StackProps = StackBaseProps & (StackGapProps | StackJustifyProps);
3738

38-
const defaultElement = "div" as const;
39+
const defaultElement = 'div' as const;
3940

4041
/** ComplexGenericUnionIntersection description */
4142
export const ComplexGenericUnionIntersection = <
4243
E extends React.ElementType = typeof defaultElement
4344
>(
4445
props: BoxProps<E, StackProps>
45-
) => <div />;
46+
) => <div />;

src/__tests__/data/ForwardRefDefaultExportAtExport.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ export interface ForwardRefDefaultExportProps {
66
}
77

88
/** ForwardRefDefaultExport description */
9-
const ForwardRefDefaultExport = (props: ForwardRefDefaultExportProps, ref: React.Ref<HTMLDivElement>) => (
10-
<div ref={ref}>My Property = {props.myProp}</div>
11-
)
9+
const ForwardRefDefaultExport = (
10+
props: ForwardRefDefaultExportProps,
11+
ref: React.Ref<HTMLDivElement>
12+
) => <div ref={ref}>My Property = {props.myProp}</div>;
1213

1314
export default React.forwardRef(ForwardRefDefaultExport);

src/__tests__/data/FunctionDeclarationVisibleName.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export interface JumbotronProps {
88

99
/**
1010
* Awesome Jumbotron description
11-
*
11+
*
1212
* @visibleName Awesome Jumbotron
1313
*/
1414
export function Jumbotron(props: JumbotronProps) {

src/__tests__/data/HOCIntersectionProps.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ export interface HOCProps {
77
}
88

99
/** HOCIntersectionProps description */
10-
export const HOCIntersectionProps: React.SFC<
11-
HOCProps & HOCInjectedProps
12-
> = props => <div />;
10+
export const HOCIntersectionProps: React.SFC<HOCProps &
11+
HOCInjectedProps> = props => <div />;
1312

1413
export default withHOC({})(HOCIntersectionProps);

src/__tests__/data/StatelessIntersectionExternalProps.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,5 @@ export interface StatelessProps {
77
}
88

99
/** StatelessIntersectionExternalProps description */
10-
export const StatelessIntersectionExternalProps: React.SFC<
11-
StatelessProps & ExternalOptionalComponentProps
12-
> = props => <div />;
10+
export const StatelessIntersectionExternalProps: React.SFC<StatelessProps &
11+
ExternalOptionalComponentProps> = props => <div />;

src/__tests__/data/StatelessIntersectionProps.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,5 @@ export interface StatelessMoreProps {
1111
}
1212

1313
/** StatelessIntersectionProps description */
14-
export const StatelessIntersectionProps: React.SFC<
15-
StatelessProps & StatelessMoreProps
16-
> = props => <div />;
14+
export const StatelessIntersectionProps: React.SFC<StatelessProps &
15+
StatelessMoreProps> = props => <div />;

src/__tests__/data/StatelessShorthandDefaultProps.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ export interface StatelessShorthandDefaultPropsProps {
1010
}
1111

1212
/** StatelessShorthandDefaultProps description */
13-
export const StatelessShorthandDefaultProps: React.SFC<
14-
StatelessShorthandDefaultPropsProps
15-
> = props => <div />;
13+
export const StatelessShorthandDefaultProps: React.SFC<StatelessShorthandDefaultPropsProps> = props => (
14+
<div />
15+
);
1616

1717
const shorthandProp = 123;
1818

0 commit comments

Comments
 (0)