Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add shouldExtractValueFromUnion and fix default value bug #21

Merged
merged 2 commits into from
Sep 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## [Unreleased]

### Added
- Support for `shouldExtractValuesFromUnion` parser option.

### Fix
- Non-string default values caused an error.

## [1.4.2] - 2020-03-29

### Fix
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ To speed things up a bit, it is recommended to include the plugin settings `incl
| skipPropsWithName | false | string[] or string | This option is passed along to `react-docgen-typescript`'s parser. It globally ignores props with the specified name(s). | `"classname"` or `["classname", "color"]` |
| skipPropsWithoutDoc | false | boolean | This option is passed along to `react-docgen-typescript`'s parser. It globally ignores props without documentation. | `true` |
| shouldExtractLiteralValuesFromEnum | false | boolean | This option is passed along to `react-docgen-typescript`'s parser. It convert string enums and unions to docgen enum format. Possible values are still accessible. | `true` |
| shouldExtractValuesFromUnion | false | boolean | This option is passed along to `react-docgen-typescript`'s parser. It convert multiple types to docgen enum format. Possible values are still accessible. | `true` |
| docgenCollectionName | false | string | Enables collecting docgen data into a global object. This is used to integrate with tools like Storybook. | `"STORYBOOK_REACT_CLASSES"` |
| include | false | string | A regular expression of files to pass along to `react-docgen-typescript`'s parser. Defaults to `\.tsx$`. | `"components.*\\.tsx$"` |
| exclude | false | string | A regular expression to filter the results from include. For instance, you can add a regular expression to prevent files ending in `.stories.tsx` from being processed in your component directories. | `"stories\\.tsx$"` |
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,6 @@
"typescript": "^3.0.1"
},
"dependencies": {
"react-docgen-typescript": "^1.16.2"
"react-docgen-typescript": "^1.20.4"
}
}
13 changes: 13 additions & 0 deletions src/__fixtures__/Component.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as React from "react";

type Size = "small" | "default" | "large";
type TabIndex = -1 | 0 | 1 | 2;
interface ButtonProps {
/**
* Label for button.
Expand All @@ -22,6 +23,16 @@ interface ButtonProps {
* Defines the size of the button.
*/
size?: Size;

/**
* Defines the tabIndex of the button.
*/
tabIndex?: TabIndex;

/**
* Defines if a button is disabled.
*/
disabled?: boolean;
}

/**
Expand All @@ -31,6 +42,8 @@ class Button extends React.Component<ButtonProps> {
static defaultProps = {
label: "label",
size: "default",
disabled: false,
tabIndex: -1,
};

render() {
Expand Down
Loading