A CLI and library to extract information from React component files for documentation generation purposes.
MIT License
Bot releases are hidden (Show)
Published by danez over 1 year ago
d7a39af: Refactored resolveComponentDefinition
utility.
findComponentDefinition
isComponentDefinition
e956802: Remove match utility.
The utility can be replaced by babel helpers and is not needed anymore. Also
using explicit checks like path.isMemberExpression()
is better for type
safety and catching potential bugs.
5215bab: Removed support for the @extends React.Component
annotation on
react class components.
Instead you can use the new @component
annotation.
80e4c74: Renamed and migrated built-in resolvers to classes.
findAllComponentDefinitions
was renamed to FindAllDefinitionsResolver
and is now a class.
-const resolver = builtinResolvers.findAllComponentDefinitions
+const resolver = new builtinResolvers.FindAllDefinitionsResolver()
findAllExportedComponentDefinitions
was renamed to
FindExportedDefinitionsResolver
and is now a class.
-const resolver = builtinResolvers.findAllExportedComponentDefinitions
+const resolver = new builtinResolvers.FindExportedDefinitionsResolver()
findExportedComponentDefinition
was removed. Use
FindExportedDefinitionsResolver
with the limit
option instead.
This is still the default resolver.
-const resolver = builtinResolvers.findExportedComponentDefinition
+const resolver = new builtinResolvers.FindExportedDefinitionsResolver({ limit: 1 })
80e4c74: Add the new ChainResolver which allows multiple resolvers to be
chained.
import { builtinResolvers } from 'react-docgen';
const { ChainResolver } = builtinResolvers;
const resolver = new ChainResolver([resolver1, resolver2], {
chainingLogic: ChainResolver.Logic.ALL, // or ChainResolver.Logic.FIRST_FOUND,
});
80e4c74: Allow resolvers to be classes in addition to functions.
import type { ResolverClass, ResolverFunction } from 'react-docgen';
// This was the only option until now
const functionResolver: ResolverFunction = (file: FileState) => {
//needs to return array of found components
};
// This is the new class resolver
class MyResolver implements ResolverClass {
resolve(file: FileState) {
//needs to return array of found components
}
}
const classResolver = new MyResolver();
5215bab: Added a new resolver that finds annotated components. This resolver
is also enabled by default.
To use this feature simply annotated a component with @component
.
// @component
class MyComponent {}
shape()
and exact()
typeof import('...')
and typeof MyType.property
correctlyPublished by danez over 1 year ago
--handlers
option to --handler
. This unifies all options80e4c74: --resolver
option can now be used multiple times.
If used multiple times the resolvers will be chained in the defined order and
all components from all resolvers will be used.
react-docgen --help
Published by danez over 2 years ago
Object.value()
calls (4fc5b21)Published by danez over 2 years ago
This is a pre-release that is under heavy development. Please report any issues you might encounter here: #579
dist
. (5f3da8c)Published by danez over 2 years ago
This is a pre-release that is under heavy development. Please report any issues you might encounter here: #576
resolveToValue
will not create a MemberExpression
for targets ending in destructuring. It will now simply resolve to the Identifier
inside the destructuring. Use new helper isDestructuringAssignment
to further check this identifier.resolveObjectValuesToArray
and resolveObjectKeysToArray
return now string[]
instead of a NodePath
Published by danez over 3 years ago
Install with
yarn add react-docgen@next
Includes all commits that are also in 5.4.0.
This version does not yet really have any breaking changes, so for updating from 5.4.0 or 5.4.0-alpha.0 nothing needs to be done. The import-resolving feature is such a big change that it will be released in the next major version, so this is the only change for now in this alpha version. Also to come in 6.0 is a complete rewrite in TypeScript, the removal of the
ast-types
dependency and some more major changes. See #502.
Published by danez over 3 years ago
This does not include #464. Resolving of imports will be added in 6.0. There is a new
6.0.0-alpha.0
version which includes resolving of imports.
componentMethodsHandler
ignores private properties (#440)@babel/generate
to serialise AST nodes w/o loc in printValue
(#482)Published by danez almost 4 years ago
Published by danez almost 4 years ago
Published by danez over 4 years ago
forwardRef
(#435)displayName
given forwardRef
node (#436)Published by danez over 4 years ago
empty
type for flow (#431)Published by danez over 4 years ago
Published by danez almost 5 years ago
Published by danez almost 5 years ago
Program
AST node as first param and recast
as second param. The new signature receives the File
AST node as first argument and the preconfigured parser as second argument.resolver(ast: ASTNode, parser: { parse: (string) => AST })
@computed#
.React.forwardRef
(#350).ts
, .tsx
). If you have babel
already setup for TypeScript in your project then all you need to do is supply the filename via the parse options. In the output there will be a new property called tsType
which will include the documentation extracted from TypeScript.parse
function can now receive a string
or a Buffer
.handler(documentation: Documentation, path: NodePath, parser: { parse: (string) => AST })
Published by danez over 5 years ago
The first prerelease of yet another breaking version, but it comes with a lot of nice goodies and three massive changes.
recast
dependency and using babel
directly for parsing the code. In our measurements we saw a 20% to 25% performance increase. If you are testing this new prerelease let us now if you see any improvement in your project.And there are more helpful changes to come till the final. Stay tuned.
This release includes all changes up to v4.1.1.
Program
AST node as first param and recast
as second param. The new signature receives the File
AST node as first argument and the preconfigured parser as second argument.resolver(ast: ASTNode, parser: { parse: (string) => AST })
@computed#
.React.forwardRef
(#350).ts
, .tsx
). If you have babel
already setup for TypeScript in your project then all you need to do is supply the filename via the parse options. In the output there will be a new property called tsType
which will include the documentation extracted from TypeScript.parse
function can now receive a string
or a Buffer
.handler(documentation: Documentation, path: NodePath, parser: { parse: (string) => AST })
Published by danez over 5 years ago
Published by danez over 5 years ago
envName
, babelrc
, root
, rootMode
, configFile
and babelrcRoots
in the programatic API. To see what this options do head over to the babel documentation
Thanks @jquense.