Skip to content
This repository was archived by the owner on Nov 20, 2020. It is now read-only.

Update react-docgen-typescript to latest and use newest options #108

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -261,14 +261,16 @@ stories.add(
| ---------------------------------- | -------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| skipPropsWithName | string[] or string | Avoid including docgen information for the prop or props specified. |
| skipPropsWithoutDoc | boolean | Avoid including docgen information for props without documentation. |
| componentNameResolver | function | If a string is returned, then the component will use that name. Else it will fallback to the default logic of parser. https://github.com/styleguidist/react-docgen-typescript#parseroptions |
| propFilter | function | Filter props using a function. If skipPropsWithName or skipPropsWithoutDoc is defined the function will not be used. Function accepts two arguments: object with information about prop and an object with information about component. Return true to include prop in documentation. https://github.com/styleguidist/react-docgen-typescript#parseroptions |
| componentNameResolver | function | If a string is returned, then the component will use that name. Else it will fallback to the default logic of parser. https://github.com/styleguidist/react-docgen-typescript#options |
| propFilter | function | Filter props using a function. If skipPropsWithName or skipPropsWithoutDoc is defined the function will not be used. Function accepts two arguments: object with information about prop and an object with information about component. Return true to include prop in documentation. https://github.com/styleguidist/react-docgen-typescript#options |
| tsconfigPath | string | Specify the location of the tsconfig.json to use. Can not be used with compilerOptions. |
| compilerOptions | typescript.CompilerOptions | Specify TypeScript compiler options. Can not be used with tsconfigPath. |
| docgenCollectionName | string or null | Specify the docgen collection name to use. All docgen information will be collected into this global object. Set to `null` to disable. Defaults to `STORYBOOK_REACT_CLASSES` for use with the Storybook Info Addon. https://github.com/gongreg/react-storybook-addon-docgen |
| setDisplayName | boolean | Automatically set the components' display name. If you want to set display names yourself or are using another plugin to do this, you should disable this option. Defaults to `true`. This is used to preserve component display names during a production build of Storybook. |
| shouldExtractLiteralValuesFromEnum | boolean | If set to true, string enums and unions will be converted to docgen enum format. Useful if you use Storybook and want to generate knobs automatically using [addon-smart-knobs](https://github.com/storybookjs/addon-smart-knobs). https://github.com/styleguidist/react-docgen-typescript#parseroptions |
| savePropValueAsString | boolean | If set to true, defaultValue to props will be string. https://github.com/styleguidist/react-docgen-typescript#parseroptions |
| shouldExtractLiteralValuesFromEnum | boolean | If set to true, string enums and unions will be converted to docgen enum format. Useful if you use Storybook and want to generate knobs automatically using [addon-smart-knobs](https://github.com/storybookjs/addon-smart-knobs). https://github.com/styleguidist/react-docgen-typescript#options |
| shouldExtractValuesFromUnion | boolean | If set to true, every unions will be converted to docgen enum format. https://github.com/styleguidist/react-docgen-typescript#options |
| shouldRemoveUndefinedFromOptional | boolean | If set to true, types that are optional will not display " \| undefined" in the type. https://github.com/styleguidist/react-docgen-typescript#options |
| savePropValueAsString | boolean | If set to true, defaultValue to props will be string. https://github.com/styleguidist/react-docgen-typescript#options |
| typePropName | string | Specify the name of the property for docgen info prop type. |

## Performance
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"dependencies": {
"@webpack-contrib/schema-utils": "^1.0.0-beta.0",
"loader-utils": "^1.2.3",
"react-docgen-typescript": "^1.15.0"
"react-docgen-typescript": "^1.20.1"
},
"peerDependencies": {
"typescript": "*"
Expand Down
16 changes: 14 additions & 2 deletions src/LoaderOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,25 @@ export default interface LoaderOptions {
/**
* If set to true, string enums and unions will be converted to docgen enum format.
* Useful if you use Storybook and want to generate knobs automatically using [addon-smart-knobs](https://github.com/storybookjs/addon-smart-knobs).
* @see https://github.com/styleguidist/react-docgen-typescript#parseroptions
* @see https://github.com/styleguidist/react-docgen-typescript#options
* */
shouldExtractLiteralValuesFromEnum?: boolean;

/**
* If set to true, every unions will be converted to docgen enum format.
* @see https://github.com/styleguidist/react-docgen-typescript#options
*/
shouldExtractValuesFromUnion?: boolean;

/**
* If set to true, types that are optional will not display " | undefined" in the type.
* @see https://github.com/styleguidist/react-docgen-typescript#options
*/
shouldRemoveUndefinedFromOptional?: boolean;

/**
* If set to true, defaultValue to props will be string.
* @see https://github.com/styleguidist/react-docgen-typescript#parseroptions
* @see https://github.com/styleguidist/react-docgen-typescript#options
* */
savePropValueAsString?: boolean;

Expand Down
3 changes: 3 additions & 0 deletions src/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ function processResource(
: options.propFilter,
shouldExtractLiteralValuesFromEnum:
options.shouldExtractLiteralValuesFromEnum,
shouldExtractValuesFromUnion: options.shouldExtractValuesFromUnion,
shouldRemoveUndefinedFromOptional:
options.shouldRemoveUndefinedFromOptional,
savePropValueAsString: options.savePropValueAsString,
};

Expand Down
8 changes: 8 additions & 0 deletions src/validateOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@ const schema = {
type: "boolean",
},

shouldExtractValuesFromUnion: {
type: "boolean",
},

shouldRemoveUndefinedFromOptional: {
type: "boolean",
},

savePropValueAsString: {
type: "boolean",
},
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3979,10 +3979,10 @@ rc@^1.2.7:
minimist "^1.2.0"
strip-json-comments "~2.0.1"

react-docgen-typescript@^1.15.0:
version "1.15.0"
resolved "https://registry.yarnpkg.com/react-docgen-typescript/-/react-docgen-typescript-1.15.0.tgz#963f14210841f9b51ed18c65152a6cc37f1c3184"
integrity sha512-8xObdkRQbrc0505tEdVRO+pdId8pKFyD6jhLYM9FDdceKma+iB+a17Dk7e3lPRBRh8ArQLCedOCOfN/bO338kw==
react-docgen-typescript@^1.20.1:
version "1.20.1"
resolved "https://registry.yarnpkg.com/react-docgen-typescript/-/react-docgen-typescript-1.20.1.tgz#774ed8b4a7111acaaa536cad4cfd61c504a46f7e"
integrity sha512-vU6puLsSwfCS+nI/6skQ52sJIx/uW7+9aMI/V/zPHAXr6s8OQzD5LeL9rXx/Hdt2aNfm4yTX9oJ8ClH/5PKQNg==

react-is@^16.8.4:
version "16.9.0"
Expand Down