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 | function | A function of the form `(ast: ASTNode, recast: Object) => (NodePath|Array<NodePath>)`. Given an AST and a reference to recast, it returns an (array of) NodePath which represents the component definition. |
87
-
| handlers | Array\<function\>| An array of functions of the form `(documentation: Documentation, definition: NodePath) => void`. Each function is called with a `Documentation` object and a reference to the component definition as returned by `resolver`. Handlers extract relevant information from the definition and augment `documentation`. |
88
-
| options | Object | Pass options to react-docgen, see below. |
| resolver | function | A function of the form `(ast: ASTNode, recast: Object) => (NodePath|Array<NodePath>)`. Given an AST and a reference to recast, it returns an (array of) NodePath which represents the component definition.|
86
+
| handlers | Array\<function\>| An array of functions of the form `(documentation: Documentation, definition: NodePath) => void`. Each function is called with a `Documentation` object and a reference to the component definition as returned by `resolver`. Handlers extract relevant information from the definition and augment `documentation`. |
87
+
| options | Object | Pass options to react-docgen, see below.|
89
88
90
89
#### options
91
90
@@ -104,6 +103,14 @@ Default: `process.cwd()`
104
103
105
104
The working directory that babel configurations will be searched in.
These options, will be passed directly to `babel` for locating and resolving a local config or babelrc. To see
112
+
documentation for each option consult the [babel website](https://babeljs.io/docs/en/options#config-loading-options).
113
+
107
114
##### ∙ parserOptions
108
115
109
116
Type: `BabelParserOptions`
@@ -129,7 +136,7 @@ module.exports = Component;
129
136
130
137
and returns the ObjectExpression to which `<def>` resolves to, or the class declaration itself.
131
138
132
-
`findAllComponentDefinitions` works similarly, but finds *all*`React.createClass` calls and class definitions, not only the one that is exported.
139
+
`findAllComponentDefinitions` works similarly, but finds _all_`React.createClass` calls and class definitions, not only the one that is exported.
133
140
134
141
This makes it easy, together with the utility methods created to analyze the AST, to introduce new or custom resolver methods. For example, a resolver could look for plain ObjectExpressions with a `render` method.
135
142
@@ -145,7 +152,7 @@ For example, while the `propTypesHandler` expects the prop types definition to b
145
152
146
153
- Modules have to export a single component, and only that component is analyzed.
147
154
- When using `React.createClass`, the component definition (the value passed to it) must resolve to an object literal.
148
-
- When using classes, the class must either `extend React.Component`*or* define a `render()` method.
155
+
- When using classes, the class must either `extend React.Component`_or_ define a `render()` method.
149
156
-`propTypes` must be an object literal or resolve to an object literal in the same file.
150
157
- The `return` statement in `getDefaultProps` must contain an object literal.
- `<propName>`: For each prop that was found, there will be an entry in `props` under the same name.
408
-
- `<typeName>`: The name of the type, which is usually corresponds to the function name in `React.PropTypes`. However, for types define with `oneOf`, we use `"enum"` and for `oneOfType` we use `"union"`. If a custom function is provided or the type cannot be resolved to anything of `React.PropTypes`, we use `"custom"`.
405
+
- `<propName>`: For each prop that was found, there will be an entry in `props` under the same name.
406
+
- `<typeName>`: The name of the type, which is usually corresponds to the function name in `React.PropTypes`. However, for types define with `oneOf`, we use `"enum"` and for `oneOfType` we use `"union"`. If a custom function is provided or the type cannot be resolved to anything of `React.PropTypes`, we use `"custom"`.
409
407
- `<typeValue>`: Some types accept parameters which define the type in more detail (such as `arrayOf`, `instanceOf`, `oneOf`, etc). Those are stored in `<typeValue>`. The data type of `<typeValue>` depends on the type definition.
410
408
- `<flowType>`: If using flow type this property contains the parsed flow type as can be seen in the table above.
0 commit comments