You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`--resolver` either accepts the name of a built-in resolver
(findExportedComponentDefinition, findAllComponentDefinitions) or a path
to a module that exports a resolver function.
With this option, react-docgen can be more easily customized. It is not
necessary anymore to create a custom script and use the API just to use
a different / custom resolver.
Copy file name to clipboardExpand all lines: README.md
+14-4Lines changed: 14 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,10 @@
4
4
5
5
It uses [recast][] and [babylon][] to parse the source into an AST and provides methods to process this AST to extract the desired information. The output / return value is a JSON blob / JavaScript object.
6
6
7
-
It provides a default implementation for React components defined via `React.createClass` or [ES2015 class definitions][classes]. These component definitions must follow certain guidelines in order to be analyzable (see below for more info).
7
+
It provides a default implementation for React components defined via
8
+
`React.createClass`, [ES2015 class definitions][classes] or functions
9
+
(stateless components). These component definitions must follow certain
10
+
guidelines in order to be analyzable (see below for more info).
8
11
9
12
## Install
10
13
@@ -31,15 +34,22 @@ Options:
31
34
--pretty pretty print JSON
32
35
-x, --extension File extensions to consider. Repeat to define multiple extensions. Default: [js,jsx]
33
36
-i, --ignore Folders to ignore. Default: [node_modules,__tests__]
37
+
--resolver RESOLVER Resolver name (findAllComponentDefinitions, findExportedComponentDefinition) or
38
+
path to a module that exports a resolver. [findExportedComponentDefinition]
34
39
35
40
Extract meta information from React components.
36
41
If a directory is passed, it is recursively traversed.
37
42
```
38
43
39
-
By default, `react-docgen` will look for the exported component created through `React.createClass` or a class definition in each file. Have a look below for how to customize this behavior.
44
+
By default, `react-docgen` will look for the exported component created through
45
+
`React.createClass`, a class definition or a function (stateless component) in
46
+
each file. You can change that behavior with the `--resolver` option, which
47
+
either expects the name of a built-in resolver or a path to JavaScript module
48
+
exporting a resolver function. Have a look below for [more information about
49
+
resolvers](#resolver).
40
50
41
-
Have a look at `example/` for an example of how to use the result to generate
42
-
a markdown version of the documentation.
51
+
Have a look at `example/` for an example of how to use the result to generate a
0 commit comments